Seven tiny lamps pretending to be a number. Wire them all and build a counting machine.
Enter the access code from the card inside your Beginner Kit (or from your GAMERIFT order email). Your name appears on every page and printout as the licensee.
Don't have a kit yet? Get the Beginner Kit, the code ships inside. Lost your code? Contact us with your order number.
Microwave clocks, petrol pumps, scoreboards, lift buttons: the seven-segment display has been showing humanity its numbers since before your parents were born. It is nothing but seven little LED bars arranged as an 8. Light the right bars and any digit appears. Today you wire all seven, teach your board the shapes of the digits, and build a counter that ticks up every time you press a button. This is the most wires you have ever used. Go slow. It is worth it.
Time: 60–75 minutes · Difficulty: 4/5, mostly patience · You need: Lesson 03 done (buttons).
Engineers name the bars a to g: a is the top bar, then clockwise around the edge, b (top right), c (bottom right), d (bottom), e (bottom left), f (top left), and g is the middle. A "7" is just a+b+c. A "8" is everything. Once you can light bars on command, digits are simply spelling.
Ten digits, seven bars each. You could write seventy digitalWrite lines... or you could hand the board a table and say "digit 4 is row 4 of the table". A list a program can look things up in is called an array, and it is one of the most useful ideas in all of coding. Today it saves you sixty lines of typing.
Hold the display with the decimal point at the bottom right. It has 5 legs on top, 5 on the bottom. The middle leg of each row is the shared ground (they are connected to each other inside, so you only need to wire one of them). Every other leg controls one bar. Our display shares ground, "common cathode", so a bar lights when its leg goes HIGH.
Unplug the USB. Straddle the display across the breadboard's middle channel like you did with the button. Wire the shared ground first, then work through the bars one by one, ticking them off on paper.
| From | To | Why |
|---|---|---|
| Bottom middle leg | 220Ω resistor → R3 GND | Shared ground, one bodyguard for all |
| R3 pin 3 | Leg for bar a (top row, right of middle) | Top bar |
| R3 pin 4 | Leg for bar b (top row, far right) | Top right |
| R3 pin 5 | Leg for bar c (bottom row, right of middle) | Bottom right |
| R3 pin 6 | Leg for bar d (bottom row, second from left) | Bottom bar |
| R3 pin 7 | Leg for bar e (bottom row, far left) | Bottom left |
| R3 pin 8 | Leg for bar f (top row, second from left) | Top left |
| R3 pin 9 | Leg for bar g (top row, far left) | The middle bar |
| R3 pin 10 | Button leg · other leg to GND | The counting trigger, like Lesson 03 |
Leg layouts can differ between displays. If a digit comes out scrambled later, don't rewire in a panic, use the Break It section's "bar test" to map YOUR display, then swap the wires calmly.
// GAMERIFT Beginner Kit, Lesson 07: Count On Me // An array holds the shape of every digit. The button counts. const int barPins[7] = {3, 4, 5, 6, 7, 8, 9}; // bars a,b,c,d,e,f,g const int buttonPin = 10; // The digit table: one row per digit, one 1/0 per bar (a to g). const int digits[10][7] = { {1,1,1,1,1,1,0}, // 0 {0,1,1,0,0,0,0}, // 1 {1,1,0,1,1,0,1}, // 2 {1,1,1,1,0,0,1}, // 3 {0,1,1,0,0,1,1}, // 4 {1,0,1,1,0,1,1}, // 5 {1,0,1,1,1,1,1}, // 6 {1,1,1,0,0,0,0}, // 7 {1,1,1,1,1,1,1}, // 8 {1,1,1,1,0,1,1} // 9 }; int count = 0; void showDigit(int n) { for (int i = 0; i < 7; i++) { digitalWrite(barPins[i], digits[n][i]); // look it up, light it up } } void setup() { for (int i = 0; i < 7; i++) { pinMode(barPins[i], OUTPUT); } pinMode(buttonPin, INPUT_PULLUP); showDigit(0); } void loop() { if (digitalRead(buttonPin) == LOW) { // pressed (upside-down, remember) count = count + 1; if (count > 9) count = 0; // only one digit, wrap around showDigit(count); delay(250); // so one press counts once } }
random(1, 7). Board-game night is saved forever.Film your counter counting for your lesson log, this build earns bragging rights, it has more wires than everything before it combined. Stuck? Photo of your wiring to contact us.
Your machines can shine and show. Next lesson they get a voice: two kinds of buzzer, a siren, and a melody you program note by note.