Build it step by step
0 of 6 doneWire the display
Connect segments a to g through resistors and the common pins to ground.
Test every digit
Temporarily loop through 0 to 9 and check each looks right.
Add the colour LED
Wire the RGB legs through resistors and test each colour.
Add the touch pad
Connect the TTP223 and check it with a Serial print.
Upload the dice
Touch the pad and watch the roll slow down and stop.
Play a round
Check the colour changes after each roll except a six.
How do you build an electronic Ludo dice?
Tap a touch pad to roll a dice that shows on a 7-segment display with the current player's colour. You need Arduino Nano, 7-segment display 1 digit (common cathode), Resistor 220 Ω × 10, Touch sensor module (TTP223) and RGB LED 5 mm common cathode. It takes 6 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 5
Parts list
- Development BoardsBuyArduino Nano × 1
- DisplaysBuy
- PassivesBuyResistor 220 Ω × 10
- SensorsBuy
- SemiconductorsBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Nano D2 to D8 | 220 Ω resistors then segments a, b, c, d, e, f, g | Display segments |
| Display common pins (3 and 8) | Nano GND | Common cathode |
| Nano D9 | 220 Ω resistor then RGB LED red leg | Red |
| Nano D10 | 220 Ω resistor then RGB LED green leg | Green |
| Nano D11 | 220 Ω resistor then RGB LED blue leg | Blue |
| RGB LED common cathode (longest leg) | Nano GND | Common |
| TTP223 VCC, GND | Nano 5V, GND | Power |
| TTP223 OUT | Nano D12 | Goes high when touched |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries needed. The 7-segment pins (5161AS type, with the decimal point at bottom right): 1 e, 2 d, 3 common, 4 c, 5 dp, 6 b, 7 a, 8 common, 9 f, 10 g. Use a 220 Ω resistor on every segment and every RGB leg.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const byte SEG[7] = { 2, 3, 4, 5, 6, 7, 8 }; // a to g
const byte RGB[3] = { 9, 10, 11 };
const byte TOUCH = 12;
// Segments a to g for digits 0 to 9
const byte DIGITS[10][7] = {
{1,1,1,1,1,1,0}, {0,1,1,0,0,0,0}, {1,1,0,1,1,0,1}, {1,1,1,1,0,0,1}, {0,1,1,0,0,1,1},
{1,0,1,1,0,1,1}, {1,0,1,1,1,1,1}, {1,1,1,0,0,0,0}, {1,1,1,1,1,1,1}, {1,1,1,1,0,1,1}
};
// Player colours: red, green, blue, yellow
const byte COLOURS[4][3] = { {1,0,0}, {0,1,0}, {0,0,1}, {1,1,0} };
byte player = 0;
void showDigit(byte d) { for (byte i = 0; i < 7; i++) digitalWrite(SEG[i], DIGITS[d][i]); }
void showPlayer() { for (byte i = 0; i < 3; i++) digitalWrite(RGB[i], COLOURS[player][i]); }
void setup() {
for (byte i = 0; i < 7; i++) pinMode(SEG[i], OUTPUT);
for (byte i = 0; i < 3; i++) pinMode(RGB[i], OUTPUT);
pinMode(TOUCH, INPUT);
randomSeed(analogRead(A0) ^ micros()); // A0 is unconnected so it picks up noise
showPlayer();
showDigit(8);
}
void loop() {
if (digitalRead(TOUCH) == HIGH) {
for (byte i = 0; i < 14; i++) { showDigit(random(1, 7)); delay(60 + i * 12); } // slowing roll
byte roll = random(1, 7); // random(1, 7) gives 1 to 6 evenly
showDigit(roll);
delay(1200);
if (roll == 6) { // an extra turn: blink the colour
for (byte i = 0; i < 3; i++) { for (byte k = 0; k < 3; k++) digitalWrite(RGB[k], LOW); delay(150); showPlayer(); delay(150); }
} else {
player = (player + 1) % 4;
showPlayer();
}
while (digitalRead(TOUCH) == HIGH) {} // wait until the pad is released
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Power on | Shows 8 and the red player colour |
| Touch the pad | Digits shuffle and stop on 1 to 6 |
| Roll a 1 to 5 | Colour moves to the next player |
| Roll a 6 | Colour blinks and the same player rolls again |
If it does not work
A segment is missing
Check its resistor and wire, and the display pinout.
Always the same numbers
Random seed is fixed. Leave A0 unconnected.
Touch pad triggers on its own
Keep it away from metal and use the power pins from the same Nano.
Colour looks wrong
Check the RGB leg order for your LED.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the electronic Ludo dice?
Arduino Nano, 7-segment display 1 digit (common cathode), Resistor 220 Ω × 10, Touch sensor module (TTP223) and RGB LED 5 mm common cathode.
How long does the electronic Ludo dice take to build?
About 60 minutes for a beginner maker, in 6 steps.
How do I know the electronic Ludo dice works?
Power on: Shows 8 and the red player colour. Touch the pad: Digits shuffle and stop on 1 to 6. Roll a 1 to 5: Colour moves to the next player.
A segment is missing: what should I check?
Check its resistor and wire, and the display pinout.
Always the same numbers: what should I check?
Random seed is fixed. Leave A0 unconnected.
Touch pad triggers on its own: what should I check?
Keep it away from metal and use the power pins from the same Nano.
Colour looks wrong: what should I check?
Check the RGB leg order for your LED.
