Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)

Target Amount: \$2000
Amount Raised: \$1579.10

Donations Received

Top Donor: C.C. \$100

X

# Tutorial 17: Electronic Dice

Created on: 6 August 2012

This circuit simulates a dice being thrown. Pressing the button "throws" the dice. One of six LEDs will light up after the throw.

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, etc.

Can't see the video? View on YouTube →

## Prerequisites

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

## 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 colour LEDs
1 Push button switch SW1 Switch

Amazon.com

Amazon.co.uk

## Circuit Diagram

Click the circuit diagram 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.

## 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 coloured 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 Circuit

Click any of the breadboard pictures for a bigger image.

In the photos, 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.

The orange jumpers also connect the the left and right horizontal rails of each set.

In this 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.

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.

## Operating the 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.

Electronic Components