Built-in project · no microcontroller

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.

The circuit runs here once the page has loaded.

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.

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 pinConnects to
4-way DIP switch pin 4B5 V
4-way DIP switch pin 3B5 V
4-way DIP switch pin 2B5 V
4-way DIP switch pin 1B5 V
CD4511 7-segment driver pin LT5 V
CD4511 7-segment driver pin BI5 V
CD4511 7-segment driver pin VDD5 V
4-resistor network pin CGround
CD4511 7-segment driver pin LEGround
CD4511 7-segment driver pin VSSGround
Resistor, 100 Ω pin 2Ground
4-resistor network pin 44-way DIP switch pin 1A
CD4511 7-segment driver pin A4-way DIP switch pin 1A
4-resistor network pin 34-way DIP switch pin 2A
CD4511 7-segment driver pin B4-way DIP switch pin 2A
4-resistor network pin 24-way DIP switch pin 3A
CD4511 7-segment driver pin C4-way DIP switch pin 3A
4-resistor network pin 14-way DIP switch pin 4A
CD4511 7-segment driver pin D4-way DIP switch pin 4A
Seven segment display pin ECD4511 7-segment driver pin e
Seven segment display pin DCD4511 7-segment driver pin d
Seven segment display pin CCD4511 7-segment driver pin c
Seven segment display pin BCD4511 7-segment driver pin b
Seven segment display pin ACD4511 7-segment driver pin a
Seven segment display pin GCD4511 7-segment driver pin g
Seven segment display pin FCD4511 7-segment driver pin f
Resistor, 100 Ω pin 1Seven 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.

sketch.ino
// 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.