Arduino Flip Number Display with 7 Servo Motors
With an Arduino and seven tiny servo motors, we built a mechanical display that flips its segments to create numbers. That’s engineering in motion!
- Level: Beginner+
- Time: about 2 hours
- Ages 10+ (with an adult helper)
What are we building?
Look at a digital clock. Every number is made of seven bars called segments. Our project uses seven wooden segments, each mounted on a blue micro servo motor. When the Arduino says “show 5”, the right servos flip their segments up and the others stay down. Change the number and the segments rapidly flip into a new shape!
Try it: tap a number to see which segments flip up.
Pick a number!
What you need
| Part | How many |
|---|---|
| Arduino Uno (or Nano) | 1 |
| SG90 micro servo motor (blue) | 7 |
| 5V 2A power supply (USB adapter or battery pack) | 1 |
| 470 µF capacitor | 1 |
| Breadboard and jumper wires | 1 set |
| Wooden craft sticks or thin plywood strips (about 6 cm × 1 cm) | 7 |
| Cardboard or foam board for the base | 1 sheet |
| Hot glue gun, double-sided tape, paint | as needed |
How it works
A servo motor turns its arm to an angle we choose, from 0° to 180°. We attach a wooden segment to each arm. At 0° the segment lies flat and hidden. At 90° it stands up and is visible. The Arduino has a list that tells it which segments to raise for each number. Seven servos, seven segments, ten digits!
Circuit diagram
Each servo has three wires. Brown is ground, red is power and orange is the signal.
Pin table
| Segment | Arduino pin | Servo wire |
|---|---|---|
| a (top) | D2 | Orange |
| b (top right) | D3 | Orange |
| c (bottom right) | D4 | Orange |
| d (bottom) | D5 | Orange |
| e (bottom left) | D6 | Orange |
| f (top left) | D7 | Orange |
| g (middle) | D8 | Orange |
| All servos | 5V supply (red), GND (brown) | Red and brown |
Step-by-step instructions
Make the segments
Cut or pick seven wooden sticks. Paint them in your favourite colour so they are easy to see. Let the paint dry fully.
Mount the servos
Arrange seven servos on the base in the shape of the number 8: three flat (top, middle, bottom) and four upright (the sides). Fix them with hot glue or double-sided tape. Glue one stick to each servo arm using the small horn that comes in the servo packet.
Wire the circuit
Follow the diagram. Connect each orange signal wire to its Arduino pin (D2 to D8). Join all red wires to the +5V supply and all brown wires to GND. Connect supply GND to Arduino GND. Double-check before switching on!
Upload the code
Open the Arduino IDE, paste the code below, choose your board and port, then click Upload.
Calibrate and play
If a segment does not lie flat or stand straight, change its two angle numbers in the code (see the tips below) and upload again. Watch your display count from 0 to 9!
Arduino code
This code uses the built-in Servo library, so there is nothing extra to install.
#include <Servo.h>
Servo seg[7]; // a, b, c, d, e, f, g
const int pins[7] = {2, 3, 4, 5, 6, 7, 8};
// Change these if a segment is not straight
int offAngle[7] = {0, 0, 0, 0, 0, 0, 0}; // lying flat
int onAngle[7] = {90, 90, 90, 90, 90, 90, 90}; // standing up
// 1 = segment up, order: a b c d e f g
const byte 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
};
void showDigit(int n) {
for (int i = 0; i < 7; i++) {
seg[i].write(digits[n][i] ? onAngle[i] : offAngle[i]);
delay(30); // small gap so the servos don't all start at once
}
}
void setup() {
for (int i = 0; i < 7; i++) {
seg[i].attach(pins[i]);
seg[i].write(offAngle[i]); // start with every segment flat
}
delay(1000);
}
void loop() {
for (int n = 0; n <= 9; n++) {
showDigit(n);
delay(1500); // show each number for 1.5 seconds
}
}
Tips and troubleshooting
A servo is buzzing or shaking
Its angle is pushing against the base. Change onAngle or offAngle for that servo by 5° to 10°.
The Arduino keeps restarting
The servos are taking power from the Arduino. Use the separate 5V supply and add the capacitor.
Nothing moves
Check that the grounds are joined together and that the orange wires are on the right pins.
The numbers look wrong
A segment may be on the wrong pin. Compare your wiring with the pin table.
What did we learn?
- Servo motors turn to exact angles.
- Arrays store lists, like our table of ten digits.
- Loops repeat jobs, like moving seven servos one by one.
- Calibration means testing and adjusting, just like real engineers do.
Try these challenges
- Add a button that counts up each time you press it.
- Make two displays side by side to show numbers up to 99.
- Add a real-time clock module to build a flip clock.
Questions kids ask
Can I use a different servo?
Yes. Any small hobby servo works, but bigger ones need a stronger power supply.
Why seven segments?
Seven bars are the smallest number of pieces that can draw all ten digits, 0 to 9.
Can it show letters too?
Some, like A, b, C, E, F and H. Add new rows to the table and try!
Comments
Post a Comment