Introduction: Linkit One - Dice

Board games are fun to play with friends and the major part of the game is the dice. And to make board games more fun I'm going to show you how create an electronic dice using an Linkit One boar and some LEDs. This game will generate a random number each time a button is clicked. You can also add in a few LEDs and make two dice out of it for a two dice game.

If you just got your Linkit One board be, sure to check out my previous instructables before diving right into this one.

Step 1: Tools and Components

So lets start with gathering all the components and tools required for this project. Most of the components come along the LinkIt one box, like battery and WiFi antenna. So here is what you need -

  • LinkIt One
  • LEDs
  • Breadboard
  • Jumper wires

Step 2: Circuit

The circuit is quite simple and can be found in the image above. All the LEDs Cathode terminal is connected together in a common cathode configuration. And the anodes of the LEDs are connected to Linkit One digital pin 1 to 6. If you are using lower voltage LED add an 330ohm resistor across the cathode and the ground terminal.

Step 3: Code

The code can be found in the attachments you can open it on a Arduino IDE. You need an Arduino IDE with Linkit Plug in to upload the code. You can check out my first tutorial on how to do that. Make sure you upload the code to the right port, you can find the your device port on device manager in windows.

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

Step 4: Play Time

After youou have uploaded the code click the Linkit One reset button and you should see the dice roll and the LED which glows represents the number on the Dice. You can also add six more LEDs and create a second dice so you can have two dice to play with. If you encountered any problems feel free to leave a comment below.