Tutorial 17: Electronic Dice

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.

Prerequisites

As a minimum, finish tutorial 5 (555 LED Flasher).

Electronic Dice Components

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

Electronic Dice Circuit Diagram

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.

Electronic dice circuit diagram
Electronic Dice Circuit Diagram
4047 and 4017 IC pinouts
4047 and 4017 IC Pinouts

Static Sensitive Parts

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:

  1. The ICs should have been shipped to you in a silver colored static shielding bag. Always store the ICs in this bag.
  2. Handling the bag and the breadboard at the same time should cause both to be at the same potential. When building the circuit, this can help to prevent a static discharge that could destroy the ICs.
  3. Don't work on a surface that is known to enhance static electricity generation.
  4. Don't wear clothes that are known to enhance the generation of static electricity.

Building the Electronic Dice Breadboard Circuit

Click any of the breadboard pictures that follow for a bigger image of the electronic dice breadboard circuit.

Breadboard Power Rails

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.

IC Power and Push Button Switch

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.

ICs and switch in breadboard
ICs and Switch on Breadboard

IC Connections and LEDs

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.

LEDs inserted into the breadboard
LEDs Added to Breadboard Circuit

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.

Finish the Breadboard Wiring

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.

The finished electronic dice circuit built on breadboard
Completed Electronic Dice Breadboard Circuit

Operating the Electronic Dice Circuit

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.

Simplifying the Circuit

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.