Projects / Electronic Ludo dice

Electronic Ludo dice

Beginner1 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO10.3

    Wire the display

    Connect segments a to g through resistors and the common pins to ground.

  2. NANO12:45

    Test every digit

    Temporarily loop through 0 to 9 and check each looks right.

  3. NANO10.4 mA

    Add the colour LED

    Wire the RGB legs through resistors and test each colour.

  4. NANOTTP223

    Add the touch pad

    Connect the TTP223 and check it with a Serial print.

  5. NANOTTP223

    Upload the dice

    Touch the pad and watch the roll slow down and stop.

  6. NANO

    Play a round

    Check the colour changes after each roll except a six.

In short

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

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Nano D2 to D8220 Ω resistors then segments a, b, c, d, e, f, gDisplay segments
Display common pins (3 and 8)Nano GNDCommon cathode
Nano D9220 Ω resistor then RGB LED red legRed
Nano D10220 Ω resistor then RGB LED green legGreen
Nano D11220 Ω resistor then RGB LED blue legBlue
RGB LED common cathode (longest leg)Nano GNDCommon
TTP223 VCC, GNDNano 5V, GNDPower
TTP223 OUTNano D12Goes 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.

CheckExpected
Power onShows 8 and the red player colour
Touch the padDigits shuffle and stop on 1 to 6
Roll a 1 to 5Colour moves to the next player
Roll a 6Colour 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 →

Ask Lark AI

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.