Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Uno 7-Segment Display: Build a Digital Dice | ShillehTek

August 30, 2026 2 views

Arduino Uno 7-Segment Display: Build a Digital Dice | ShillehTek
Project

Build an Arduino Uno digital dice with a 7-segment display and roll button, using random() with proper seeding for fair 1 to 6 rolls at ShillehTek.

45 min Beginner5 parts

Project Overview

Arduino Uno digital dice with a 7-segment display: Build a press-to-roll electronic die that flickers through numbers and lands on 1 to 6 using random() and a single button. This project teaches you how to drive a 1-digit 7-segment display segment-by-segment and how to seed randomness correctly so your rolls are not predictable after reset.

  • Time: ~45 minutes
  • Skill level: Beginner
  • What you will build: A press-to-roll die that flickers through numbers and lands on 1 to 6 on a 7-segment display you drive segment by segment.
Arduino Uno digital dice concept shown next to board game dice
Game night, upgraded: the die that never gets lost.

Parts List

From ShillehTek

External

  • None

Note: A 7-segment digit is just seven LEDs named a to g. Common-cathode: segments light when driven HIGH. Learn one digit here and multi-digit displays are the same idea multiplexed.

Step-by-Step Guide

Step 1 - Wire the Display and Button

Goal: Seven segments, one button.

What to do: Wire segments a to g to Arduino pins D2 to D8 through 220a9 resistors (one resistor per segment). Connect both common-cathode pins on the display to ground. Wire the roll button from D10 to ground and use INPUT_PULLUP. Check your display's datasheet leg map; the middle pins are usually the commons.

Expected result: Every segment is testable with a quick digitalWrite.

Step 2 - Digits as Bit Patterns

Goal: Encode 1 to 6 as segment maps.

What to do: Each number is a pattern of which segments light. Store them in an array of bytes (bit 0 = segment a, bit 6 = segment g) and use one function to display any digit:

Code:

const int segPins[7] = {2, 3, 4, 5, 6, 7, 8};   // a b c d e f g
const int BTN = 10;

//                         gfedcba
const byte digits[7] = { 0b0000000,   // (unused 0)
                         0b0000110,   // 1
                         0b1011011,   // 2
                         0b1001111,   // 3
                         0b1100110,   // 4
                         0b1101101,   // 5
                         0b1111101 }; // 6

void show(int n) {
  for (int s = 0; s < 7; s++)
    digitalWrite(segPins[s], bitRead(digits[n], s));
}

void setup() {
  for (int s = 0; s < 7; s++) pinMode(segPins[s], OUTPUT);
  pinMode(BTN, INPUT_PULLUP);
  randomSeed(analogRead(A0));    // floating pin noise = real randomness
  show(1);
}

void loop() {
  if (digitalRead(BTN) == LOW) {
    for (int i = 0; i < 12; i++) {      // roll animation
      show(random(1, 7));
      delay(60 + i * 15);                // slowing flicker, casino style
    }
    show(random(1, 7));                  // the actual roll
    delay(300);
  }
}

Expected result: Press the button; numbers flicker, slow down, and land on your roll.

Step 3 - Seed It Right

Goal: Fair dice, every power-up.

What to do: Without randomSeed(analogRead(A0)), the Arduino rolls the identical sequence after every reset. Reading a floating analog pin harvests electrical noise as a seed.

Expected result: Different rolls after every reset.

Step 4 - House Rules

Goal: Extend the game.

What to do: Two dice? Show two rolls in sequence, or add a second display. D20 for tabletop night? Switch to random(1, 21) with a 2-digit display. Add a buzzer chirp per flicker for the full slot-machine feel; the KY-006 from the melody tutorial drops right in.

Expected result: A gadget that actually gets used on game night.

Conclusion

This Arduino Uno digital dice build combines three fundamentals: driving a 7-segment display with bit patterns, animating with timed loops, and seeding real randomness so the roll is not predictable after reset. Once you can control one digit reliably, scaling to more digits is the same idea with multiplexing.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Credits

All photos and images in this tutorial are credited to Ingo Lohs on Hackster.io. The original guide by Ingo Lohs served as the reference for this ShillehTek version. We thank him for the excellent work in the maker community.