Introduction: Linkit ONE: Dice
Wouldn't it be fun if you play a game with an electronic dice? This can be a good way to impress your friends or make them jealous!
The project, as can be clearly seen from the cover picture uses the Mediatek linkit one for processing. As you reset the board, it will show you a random number through a set of 6 LEDs. The number of LEDs that light up indicates the number. Each LED is connected through a transistor so as to increase it's brightness.
So let's get started with making this project!!
The project, as can be clearly seen from the cover picture uses the Mediatek linkit one for processing. As you reset the board, it will show you a random number through a set of 6 LEDs. The number of LEDs that light up indicates the number. Each LED is connected through a transistor so as to increase it's brightness.
So let's get started with making this project!!
Step 1: Parts Required
The following parts and tools are required to make this project:
- Linkit one
- Battery
- Breadboard
- LEDs (6)
- Transistors (6)
- Jumper wires
- Linkit one
- Battery
- Breadboard
- LEDs (6)
- Transistors (6)
- Jumper wires
Step 2: Connect the Battery
The first step to complete this project is to connect the battery to linkit one. You can also power it with a USB cable but battery would make it portable. Connect it to it's socket.
Step 3: Connect the LEDs
Now this is an important step. You have to now connect all the six LEDs to linkit one with a transistor for each one. Follow the images above for reference. The digital pins that you have to use are- pins 2-7.
Step 4: Upload the Code
Upload the code given below to your linkit one. The switches should be in SPI, UART and USB positions respectively.
\\
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
int a = random(1, 6);
if(a == 1)
{
digitalWrite(1, HIGH);
}
if(a == 2)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
}
if(a == 3)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
}
if(a == 4)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
if(a == 5)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
}
if(a == 6)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
}
void loop()
{
}
\\
\\
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
int a = random(1, 6);
if(a == 1)
{
digitalWrite(1, HIGH);
}
if(a == 2)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
}
if(a == 3)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
}
if(a == 4)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
if(a == 5)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
}
if(a == 6)
{
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
}
void loop()
{
}
\\
Step 5: Test
The last step is to test your dice after everything is done. Simply switch it on and you would see a random number of LEDs light up. If you reset it, again a random number of LEDs would light up indicating a random number.
This is the end of this instructable. Thanks for watching it!!
This is the end of this instructable. Thanks for watching it!!