BCD display
Four DIP switches set a number in binary and a CD4511 shows it as a digit on a seven-segment display. There is no microcontroller in it: the simulator solves the 5 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
Teaching? Assign it to your class in one click.
Beginner About 20 minutes to build and run. Runs in your browser. Free, and no account needed.
The parts retail for about $6.40. On Mokxi they're free.
What you'll learn
- Binary-coded decimal: one decimal digit stored in four bits
- What a seven-segment decoder chip does for you
- Pull-down resistors keeping switch inputs from floating
- Tying unused control pins high or low
- Difficulty: Beginner
- Time: About 20 minutes
- Parts: 7
How it works
Four DIP switches each connect a CD4511 input to 5 V when they are on. The resistor network pulls each input to ground when its switch is off, so every input is always a clean high or low.
The CD4511 reads the four inputs as a binary number and lights the matching segments of the seven-segment display. Switch 1 is worth 1, switch 2 is worth 2, switch 3 is worth 4 and switch 4 is worth 8. The 100 ohm resistor on the display's common pin limits the current.
Parts list
7 parts, plus the jumper wires. They retail for about $6.40; on Mokxi they're free.
- 1 × Full-size breadboard
- 1 × Power, 5 V
- 1 × 4-way DIP switch
- 1 × 4-resistor network
- 1 × CD4511 7-segment driver
- 1 × Seven segment display
- 1 × Resistor, 100 ΩIn Starter Kit, Claw Machine Kit, Halloween Prop Kit.
Wiring table
Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.
| Part and pin | Connects to |
|---|---|
| 4-way DIP switch pin 4B | 5 V |
| 4-way DIP switch pin 3B | 5 V |
| 4-way DIP switch pin 2B | 5 V |
| 4-way DIP switch pin 1B | 5 V |
| CD4511 7-segment driver pin LT | 5 V |
| CD4511 7-segment driver pin BI | 5 V |
| CD4511 7-segment driver pin VDD | 5 V |
| 4-resistor network pin C | Ground |
| CD4511 7-segment driver pin LE | Ground |
| CD4511 7-segment driver pin VSS | Ground |
| Resistor, 100 Ω pin 2 | Ground |
| 4-resistor network pin 4 | 4-way DIP switch pin 1A |
| CD4511 7-segment driver pin A | 4-way DIP switch pin 1A |
| 4-resistor network pin 3 | 4-way DIP switch pin 2A |
| CD4511 7-segment driver pin B | 4-way DIP switch pin 2A |
| 4-resistor network pin 2 | 4-way DIP switch pin 3A |
| CD4511 7-segment driver pin C | 4-way DIP switch pin 3A |
| 4-resistor network pin 1 | 4-way DIP switch pin 4A |
| CD4511 7-segment driver pin D | 4-way DIP switch pin 4A |
| Seven segment display pin E | CD4511 7-segment driver pin e |
| Seven segment display pin D | CD4511 7-segment driver pin d |
| Seven segment display pin C | CD4511 7-segment driver pin c |
| Seven segment display pin B | CD4511 7-segment driver pin b |
| Seven segment display pin A | CD4511 7-segment driver pin a |
| Seven segment display pin G | CD4511 7-segment driver pin g |
| Seven segment display pin F | CD4511 7-segment driver pin f |
| Resistor, 100 Ω pin 1 | Seven segment display pin COM1 |
The notes that come with it
There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.
// Binary in, decimal out: a CD4511 decoding four switches.
//
// Switch 1 is worth 1, switch 2 is worth 2, switch 3 is worth 4 and switch 4
// is worth 8. Click the levers (up is ON) and the display shows the total:
//
// off off off off -> 0 on on on off -> 7
// on off off off -> 1 off off off on -> 8
// off on off off -> 2 on off off on -> 9
//
// That is BCD, binary-coded decimal: one decimal digit in four bits. Try
// 10 to 15 (switches 2 and 4 on is 10): the 4511 blanks the display, because
// those codes are not a decimal digit. And look at the 6 and the 9, which have
// no tails on a 4511, unlike most displays driven from a microcontroller.
//
// The 4511 has three more pins that are tied off here: LT (lamp test) and BI
// (blanking) to 5 V, and LE (latch enable) to ground so the display follows
// the switches. Move LE to 5 V and the digit freezes whatever the switches do.
Troubleshooting
The usual mistakes with this circuit, and the fix for each.
- The display goes blank for some switch settings This project
That is normal. Settings from 10 to 15 are not decimal digits, so the CD4511 blanks the display. - The digit will not change when you flip switches This project
Check that the LE pin goes to ground. If LE is at 5 V the chip holds the last digit. - The whole display stays dark This project
Check that VDD, LT and BI go to 5 V, VSS goes to ground, and the 100 ohm resistor links the display's common pin to ground. - The input reads random values when a switch is off. 4-way DIP switch
An open switch leaves the pin floating. Use INPUT_PULLUP and wire the other side of each switch to GND, or add a 10 k pull-down resistor on each input. - Switch positions read backwards. 4-way DIP switch
ON closes the switch to the other side. With a pull-up, ON reads LOW. Invert the value in code so that ON means 1. - The network is wired wrong and acts open. 4-resistor network
A bussed network has one common pin, usually marked with a dot, shared by all resistors. Join it to the supply for pull-ups or to ground for pull-downs. - Pull values are too weak or too strong. 4-resistor network
Choose the value for the job: 4.7 kohm to 10 kohm for logic pull-ups, and 1 kohm to 2.2 kohm for I2C. Check the pin count against the pins it serves. - The wrong segments light, or the digit is blank. CD4511 7-segment driver
Use a common cathode display. Pull LT (lamp test) and BL (blank) high, and keep LE (latch) low for live changes. A BCD value above 9 blanks the display.
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.