Skip to content

Commit a8d631d

Browse files
authored
Create README.md
1 parent d3dd19a commit a8d631d

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

Trinket_React_Counter/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## TrinketReactCounter
2+
Trinket sketch to build a react or 'like' button that counts button presses and
3+
displays them on a 7-segment or 14-segment LED backpack.
4+
5+
The files in this repository accompany an [Adafruit Learning System](https://learn.adafruit.com) tutorial
6+
https://learn.adafruit.com/trinket-react-counter
7+
8+
This code was formerly at https://github.com/adafruit/TrinketReactCounter - this has now been archived.
9+
10+
All code MIT License, please keep attribution to Adafruit Industries
11+
12+
If you are looking to make changes/additions, please use the GitHub Issues and Pull Request mechanisms.
13+
14+
Please consider buying your parts at [Adafruit.com](https://www.adafruit.com) to support open source code.
15+
16+
## Hardware
17+
18+
You need the following hardware to build this device:
19+
20+
* [Adafruit Trinket](https://www.adafruit.com/trinket) (either the [5V Trinket](https://www.adafruit.com/products/1501) or [3.3V Trinket](https://www.adafruit.com/products/1500) will work)
21+
* [Adafruit 7-segment LED Backpack Display](https://www.adafruit.com/product/879) or [Adafruit 14-segment quad alphanumeric LED Backpack Display](https://www.adafruit.com/product/1911)
22+
* [Momentary push button](https://www.adafruit.com/products/1009)
23+
24+
Connect the hardware as follows:
25+
26+
* Trinket 3V/5V power to 7-segment power (+) and one side of the button. If
27+
using the 14-segment display connect 3V/5V power to the additional power (+) pin.
28+
* Trinket #0 to 7-segment SDA (D).
29+
* Trinket #1 to opposite side of button.
30+
* Trinket #2 to 7-segment SCL (C).
31+
* Trinket GND/ground to 7-segment ground (-).
32+
33+
## Usage
34+
35+
Load the right sketch in Arduino depending on your hardware. The 7-segment display
36+
should use the TrinketReactCounter_7segment sketch, and the 14-segment quad alphanumeric
37+
display should use the TrinketReactCounter_14segment sketch. Make sure the following
38+
libraries are installed too (using the library manager or a manual install):
39+
40+
* [Adafruit GFX Library](https://github.com/adafruit/Adafruit-GFX-Library)
41+
* [Adafruit LED Backpack](https://github.com/adafruit/Adafruit_LED_Backpack)
42+
43+
For your first use uncomment this line near the top of the sketch:
44+
45+
// Uncomment the line below to reset the counter value in EEPROM to zero.
46+
// After uncommenting reload the sketch and during the setup the counter
47+
// will be reset. Then comment the line again and reload to start again
48+
// (if you don't comment it out then every time the board powers on it
49+
// will reset back to zero!).
50+
//#define RESET_COUNT
51+
52+
So that it looks like the following:
53+
54+
// Uncomment the line below to reset the counter value in EEPROM to zero.
55+
// After uncommenting reload the sketch and during the setup the counter
56+
// will be reset. Then comment the line again and reload to start again
57+
// (if you don't comment it out then every time the board powers on it
58+
// will reset back to zero!).
59+
#define RESET_COUNT
60+
61+
This will cause the count stored in EEPROM to be reset to zero during the setup.
62+
63+
Save and upload the modified sketch to the Trinket. You should see the display print 0.
64+
If you press and release the button the count should increment by one.
65+
66+
Now back in the sketch code comment out the RESET_COUNT line again so it looks
67+
like its original value:
68+
69+
// Uncomment the line below to reset the counter value in EEPROM to zero.
70+
// After uncommenting reload the sketch and during the setup the counter
71+
// will be reset. Then comment the line again and reload to start again
72+
// (if you don't comment it out then every time the board powers on it
73+
// will reset back to zero!).
74+
//#define RESET_COUNT
75+
76+
Upload the sketch to the Trinket again. You should see the display print the
77+
previous count value, and again pressing the button will increment the count.
78+
Now if you power down and then power back up the Trinket it should load the
79+
last count value after the bootloader runs (the red light stops pulsing).
80+
81+
You can follow the above steps to uncomment the RESET_COUNT value any time you
82+
want to reset the count value back to zero.

0 commit comments

Comments
 (0)