Search The E.T. Blog

Sunday, 5 October 2014

Electronic Dice Simple Arduino Project - DIY

Wandering around I found an interesting project to do on your Arduino. It's a electronic dice so, next time you play ludo or monopoly you don't need any more the conventional dice. I made it myself too. I will give here the program also.


Simply getting to the project the things we will need are:-

1. (2) 330 ohms resistors or (1) 560 ohms
2. 6 LEDs
3. Arduino
4. Some Connecting wires
5. 9 volt battery
6. Battery Clip
7. Bread Board

So, here's the circuit diagram





Now we you can build this circuit as it is very simple. After making the connections the circuit will look like this



Here we have a nice simple circuit. Now come the programming part. Go to this page and you can download the code - Electronic dice
Your browser will not be able to preview this rather, download this or if you are using Google Chrome ( not sure about other browsers ) there will option of a third party app " Drive Notepad " which can give a preview or you can download it too.

I hope that you find this project fun and try it yourself. Any doubt about programming or circuit you can mail me or comment here below. All queries will be solved.

Like us on Facebook - Electronics Time
Follow me Google+ by clicking the Follow button above

Some people were not able to download the code so here I am writing the code:-

// electronic dice 
void setup()
{
  randomSeed(analogRead(0)); // seed a random number generator
  for( int z=1 ; z<7 ; z++) 
  { 
    pinMode(z , OUTPUT); // LEDs 1-6 are output
  }
}
void randomLED( int del )
{
  int r; 
  r = random(1,7); // get a random number from 1-6
  digitalWrite(r , HIGH); // output to the matching LED digital pin 1-6
  if (del > 0)
  {
    delay(del); // hold LED on for the delay recieved
  }
  else if ( del == 0)
  {
    do // the delay entered was zero, hold the LED on forever
    {}
    while (1);
  }
  digitalWrite( r , LOW);// turn LED off
}
void loop()
{
  int a;
  // cycle the LEDs around for effect
  for ( a=0 ; a<100 ; a++)
  {
    randomLED(50);
  }
  // slow down
  for ( a=1 ; a<=10 ; a++)
  {
    randomLED(a*100);
  }
  // and stop at the final random number and LED
  randomLED(0);

}


references (project/circuit diagram):- Project 











No comments:

Post a Comment