Created on: 6 August 2012
Updated on: 30 January 2023
This electronic dice circuit simulates a dice (or rather the singular of dice which is die) being thrown. Pressing the button "throws" the dice (or die). One of six LEDs lights up after the throw which gives the value of the throw between 1 and 6.
The LEDs have values from left to right of one to six. If the second LED lights up, the value thrown is 2, if the fifth LED lights up, the value thrown is 5, and so on.
The circuit can be seen operating in the following video.
As a minimum, finish tutorial 5 (555 LED Flasher).
In addition to a breadboard, wire links, 9V battery and battery clip, you will need:
Qty | Part | Designator | Notes | Type |
---|---|---|---|---|
1 | 10k resistor | R7 | 1/4W 5% or better | Resistors |
6 | 2k2 resistors | R1 to R6 | ||
1 | 10n capacitor | C1 | Non-polorized capacitor | Capacitor |
1 | 4047 | U1 | 4047 IC e.g. CD4047 (14 pin IC) | Semiconductor |
1 | 4017 | U2 | 4017 IC e.g. HCF4017 (16 pin IC) | |
6 | 5mm Red LEDs | D1 to D6 | Or other color LEDs | |
1 | Push button switch | SW1 | Switch |
Click the electronic dice circuit diagram below for a bigger image. New in this tutorial is the two 4000 series logic ICs, the 4047 and 4017. The outlines with pin numbering of these two ICs are shown below the circuit diagram.
Sometimes the schematic symbol of an IC will not show the power and ground pins of the IC, as is the case in this circuit. This makes the schematic diagram simpler, especially when a number of ICs are used. The power and ground pin numbers are usually shown in a text box as you can see in this circuit.
First note that the two 4000 series logic ICs (4047 and 4017) are sensitive to static electricity. The static electricity from your body or other sources can destroy or partly destroy the IC.
Strictly speaking, an anti-static bench mat and wrist strap should be used when handling and working with these ICs. Not every hobbyist will have this equipment or want to spend the money on it. There are some precautions that can be taken:
Click any of the breadboard pictures that follow for a bigger image of the electronic dice breadboard circuit.
In the photos that follow, the breadboard top horizontal rail is used for the positive battery and circuit connections. The horizontal rail just below it is used for the negative (or GND) connection.
The bottom horizontal rail is used for negative connections and the one above it is used for positive connections. This is made possible by the two wires (red and black) on the left of the photo that connect positive and negative from the top horizontal rails to the bottom horizontal rails.
The orange jumpers connect the the left and right horizontal rails of each set. Your breadboard may have continuous top and bottom horizontal rails that don't need to be connected.
In the following photo, all power connections have been made from the ICs to the horizontal rails. All IC pins that are shown to be connected to +9V and GND (negative or 0V) in the circuit diagram have been made on the breadboard. A push button switch has also been inserted into the breadboard.
In the next photo, the connection between pin 5 and 15 of U2 has been made. The connection from pin 13 of U1 to pin 14 of U2 has been made. Six LEDs have been inserted with the anodes (longer LED lead) to the left. Each cathode of each LED is connected to GND with a 2k2 resistor.
The position of the LEDs and resistors have been swapped around on this breadboard circuit. I.e. in the circuit diagram, the resistors connect to U2 and then to the LEDs. In the breadboard image, the LEDs are connected to U2 and then to the resistors. This makes no difference to the way the circuit operates.
The circuit has now been completed by connecting the LED anodes to U2. C1 and R7 have been connected to U1 and wired to the push button switch.
After connecting the battery, one of the LEDs will switch on. To throw the dice, close the switch and then open it. The number of the LED, counting from the left, that is on will be the number that was "thrown" on the dice.
It is possible to connect each anode of each LED to it's corresponding pin on U2 directly without a resistor. Afterwards all of the LED cathodes can be joined and taken down to GND with one 2k2 resistor. LEDs always need a current limiting resistor, so never directly connect the cathodes to GND. There must either be a resistor connected to each cathode, or to each anode. Or in the case of this circuit, the cathodes can be connected together and taken to GND with one current limiting resistor.
Ordinarily each LED requires it's own current limiting resistor, but when only one LED is to be switched on at a time, as is done in this circuit, then a single current limiting resistor will do for all of the LEDs. If only one current limiting resistor is used, a lot of extra jumper wires are needed to connect the LED cathodes together. Because of this, using one resistor per LED may be more practical when building the circuit on a breadboard.