DSCF0422

PROJECT 0 – LED DICE

PROJECT 0

LED DICE

Back to Arduino Tutorial                                                                                          Go to Project 1

Dice, which all of us are normally will use it when playing a games especially monopoly. But have we ever head of LED dice? LED dice, one of the interesting project using LED except from LED blinking. In here, we going to experience on how to make an LED dice with a few LEDs interface with Arduino Duemilanove.

———————————————————————————————————————————————————-

COMPONENT NEEDED

———————————————————————————————————————————————————-

ARDUINO-PROTOTYPING SHIELD
JUMPER WIRE
  LEDs
  1K RESISTOR

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-
Firstly, we arrange the LEDs like the shape of the dice. Then connect the LED1 to LED7 to digital port-2 until port-8. Connect a pull-up switch to control the operation of the LED dice which is connected to digital port 11. Every LEDs are connected with an 1K resistor to prevent over current LED which will make the LED spoil.
Capture

———————————————————————————————————————————————————-

ADDITIONAL INFORMATION

———————————————————————————————————————————————————-
ARDUINO PROTOTYPING SHIELD
This is a design for an open-source prototyping shield for Arduino NG/Diecimila. It has tons of cool features, to make prototyping on your Arduino easy.
Please refer to Arduino Prototyping Shield schematic for detail connection.

Features:

  • Reset button up top
  • ICSP header
  • Lots of GND and +5V rails
  • DIP prototyping area makes it easy to add more chips.
  • SOIC prototyping area above USB jack for up to 14-pin SOIC chip, narrow medium or wide package.
  • A ‘mini’ breadboard included
  • Extra 6mm button
  • Compatible with: Arduino Duemilanove, Arduino NG, Arduino Diecimila.

LIGHT EMITTING DIODE
There are few method to determine the anode and cathode side of the LED such as :
1. The flat spot on the lens/case of the LED is cathode.
2. The short lead (or leg) is cathode.
3. The flag symbol inside the lens is cathode.

For further information about LED, please refer to this webpage.

BREADBOARD
Figure above have shows that the connection of half of the breadboard. The RED and BLACK colour line are usually been connect to power supply (VDD) and ground (GND). They are connected all the way from the beginning to the end but they did not connect to each other.

Besides that, the orange colour line are the part that we usually use to place the electronic component. They are connected in a straight line.

There is a gap in the middle of the breadboard which are not connected to anything. This allow you to put integrated circuit across the gap and have each pin of the chip go to the different set of holes and therefore a different rial.

RESISTOR COLOUR TABLE

Above are the example of resistor with the colour code example. For more detail, refer to this webpage.

———————————————————————————————————————————————————-

CODE OVERVIEW

———————————————————————————————————————————————————-

const int pinLeds1 = 2;
Define Arduino pin 2 as pinLeds1 and so on for total of 7 LEDs.

unsigned char ran = 0;
Define ran as 0 while defining the maximum storage as a byte.

Int buttonState;
Define the buttonState as an integer.

void setup ()
In here, we use to declare the pin using whether is Input or output pin.

pinMode (pinLeds1, OUTPUT);
Declare the pin as an OUTPUT pin.

pinMode (buttonPin, INPUT);
Declare the pin as an INPUT pin.

randomSeed(analogRead(0));
Initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence.

void loop()
The program under void loop will be loop forever.

ButtonState = digitalRead(buttonPin);
Read the input value from buttonPin = 11, then store the result in ButtonState.

while (buttonState == LOW){
ran =random(1,7)};
Loop forever until the buttonState,LOW(0), is detected. After that execute the random number choosing between 1 to 7.

if (ran == 1)
If ran is 1 then execute the following program.

digitalWrite (pinLeds4, HIGH)
Digitally write the pinLeds4 to High(1) the digital pin 4.

delay(50);
Delay for 50ms.

while(digitalRead(buttonPin) == HIGH);
Check if the button pin is release. If yes, then stay there until is press again.

led_clear();
Call and execute the led_clear program.


This subroutine are operate to LOW(0) or off all the LED pins by digitally write the pinLeds from 1 to 7 to LOW(0).

Back to Arduino Tutorial                                                                                       Go to Project 1

———————————————————————————————————————————————————-

 ATTACHMENT

1. P0 User Manual.pdf
2. Project_0_code.zip

Buy

,

Related Post

4x4x4 LED Cube using Arduino UNO without extra IC

Green

Lighting up RGB LED Strip – Arduino

connection_new

Project 1 – LED Blinking: LED Chaser

4 thoughts on “PROJECT 0 – LED DICE

  1. Why a dice need 7 LEDs ? And the schematic diagram and the programming code is totally a wrong way!

    The LEDs is connected such that the cathode is connected to the I/O pin and all the positive are connected to the positive VCC rail. This means I have to make the LEDs I/O pin to be LOW so that only the LEDs will light up isnt that ? Another way round is I connected all the cathode of the LEDs to GND and then connect each LEDs anode pin to the I/O pin. Then the programming code provided by Cytron is correct where HIGH is assigned.

    Correct me if I am wrong.

    Thank you 🙂

  2. Btw, tried.It works also. But I dont understand, no matter how you connect and when you program digitalWrite(Led, HIGH), then the Led will HIGH regarless of how it is connected ?

  3. the LED circuit diagram is wrong, we need to analysis the code by refer to the LED number.

Leave a Reply

Your email address will not be published. Required fields are marked *