Arduino Challenges

Rolling the Digital Dice 🎲

Deborah wants to create a digital game dice using her Arduino board.

She connected 7 red LEDs to digital pins 2, 3, 4, 5, 6, 7, and 8 of her Arduino:

She started writing the code to display the different numbers on her dice, but got a little lost. Can you help her by completing the code?

The code should count the numbers starting from 1 and up to 6 by lighting the LEDs according to the standard dice pip pattern:

Dice pip pattern

The code currently shows the number "1" by lighting LED 5 . Deborah wants to display all the 6 possible states in sequence.

Good luck!

Have questions? Feedback? Please share with us below:


void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);

void displayNumber(int num) {
  // Deborah needs some help here... Can you help her?
  digitalWrite(5, HIGH);

void loop() {
  for (int i = 1; i <= 6; i++) {