Arduino Binary Dice © CC BY-NC-SA
DESCRIPTION

Maybe you have played ludo in this quarantine. I am almost sure that you use normal dice. Well, that is until today.

If you are a maker, I am pretty sure that the next time you play ludo you will use the binary dice that I present in this post.

You will only need an Arduino Uno and a few other components that I am sure you have.

It works is very simple. You only have to push the button and the LEDs show you the number. I use three LEDs to represent the number. If you do not know about binary, you only need to sum the number that appears below the LED or LEDs that are turned on.

I leave a video with an explanation about this project. I hope you know some Spanish.

I hope you enjoy this project. See you soon.

Description:

Description:

Maybe you have played ludo in this quarantine. I am almost sure that you use normal dice. Well, that is until today.

If you are a maker, I am pretty sure that the next time you play ludo you will use the binary dice that I present in this post.

You will only need an Arduino Uno and a few other components that I am sure you have.

It works is very simple. You only have to push the button and the LEDs show you the number. I use three LEDs to represent the number. If you do not know about binary, you only need to sum the number that appears below the LED or LEDs that are turned on.

I leave a video with an explanation about this project. I hope you know some Spanish.

I hope you enjoy this project. See you soon.

Description:

Binary Dice CodeArduino
// Binary Dice
// www.rjconcepcion.com

// Variable declaration
int const d1 = 2;
int const d2 = 4;
int const d3 = 6;
int const btn = 12;

// aleatory number variable
int number = 0; 

void setup() {
  Serial.begin(9600);

  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(btn, INPUT_PULLUP); // Set input with pullup resistor

  randomSeed(analogRead(0)); // Inicialize random number generator

}

void loop() {
  
  // Start with all leds on.
  digitalWrite(d1, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(d3, HIGH);
  
  
  // Read buttom state
  if (digitalRead(btn) == LOW) {
    delay(20);

    if (digitalRead(btn) == LOW) {
      number = random(7);         // Generate a random number between 0 and 6.
    }
  }

  // Switch case structure allows to take an action depends number value. Every case represent a binary number using leds.
  switch (number) {
    case 0:
      break;

    case 1:
      digitalWrite(d1, HIGH);
      digitalWrite(d2, LOW);
      digitalWrite(d3, LOW);
      delay(5000);
      break;

    case 2:
      digitalWrite(d1, LOW);
      digitalWrite(d2, HIGH);
      digitalWrite(d3, LOW);
      delay(5000);
      break;

    case 3:
      digitalWrite(d1, HIGH);
      digitalWrite(d2, HIGH);
      digitalWrite(d3, LOW);
      delay(5000);
      break;

    case 4:
      digitalWrite(d1, LOW);
      digitalWrite(d2, LOW);
      digitalWrite(d3, HIGH);
      delay(5000);
      break;

    case 5:
      digitalWrite(d1, HIGH);
      digitalWrite(d2, LOW);
      digitalWrite(d3, HIGH);
      delay(5000);
      break;

    case 6:
      digitalWrite(d1, LOW);
      digitalWrite(d2, HIGH);
      digitalWrite(d3, HIGH);
      delay(5000);
      break;

    default:
      break;
    
  }

  number = 0; 

  delay(250);
  digitalWrite(d1, LOW);
  digitalWrite(d2, LOW);
  digitalWrite(d3, LOW);
  delay(250);

}

Description:

Diagram
Diagrama dado binario 9kwf4mjoq2


YOU MIGHT ALSO LIKE

Arduino Binary Dice © CC BY-NC-SA

Are you playing ludo in this quarantine? If you are. I have created a binary dice for you. You just need an Arduino and a few components. Maybe you have played ludo in this quarantine. I am almost sure that you ... show more