BCD-Clock with RPi zero W

Simple LED BCD-Clock with a Raspberry Pi Zero W using Python and pigpio-lib

Public Chat
Similar projects worth following
A classic BCD (binary coded decimal) clock with 18 or 20 LEDs (12h or 24h) controlled by a Raspberry Pi Zero W (RPi) in Python.

The goal:
Reduce the electronic components to an absolute minimum. No additional PCBs or parts (shift register, port expander, driver, resistors, …) are needed.

Just glue 18 or 20 standard LEDs into a front panel and wire them directly to the RPi pads. The soldering is reduced to cables between LEDs and RPi. The clock can be powered over a Micro-USB-cable from a mobile phone power supply.

• The transitions between time values are blended via PWM for all LEDs.
• The PWM is also used to let those LEDs that are off glow a bit for better reading at night.
• 12 and 24 hour format.
• Additional LEDs for am/pm and colon can be configured in software.
• The current time is received via NTP over WiFi.
• 6 free pins for additional gadgets (I²C, 1-Wire, serial, GPIO, …).

Easy to Build

Reducing the electronic components to one RPi, the LEDs, and the wires between them allows you to concentrate on the form and design.


Using standard LEDs with a maximum of 3.1 volts. Any color and shape you like.

The current to the LEDs is limited by the RPi to 2 mA per GPIO via software. Possible values are 2, 4, 8, 16 (higher than 4 is not recommended). The usual resistor in line of the LED is not needed!


The RPi can be powered over a Micro-USB cable. Use a mobile phone power supply (for USB) or a nearby PC/server with USB.

The typical current on the 5 volts line is about 100 mA with peaks up to 300 mA when WiFi fires.


The clock is implemented in the Python file ~/piClock/ It can be adapted to use a different pin to LED mapping, and 2 additional pins can be defined to extend the displayable hours to 24.


To use low voltage bulbs (5...24V), you can add 3 line driver ICs like the ULN2003 or ULN2803 directly to the RPi without a level shifter.

To use a pure binary display (6 LEDs for minutes/seconds) the python program can be easily adapted.

Pins for I²C, 1-Wire, serial and button are left free for additional IoT gadgets for e.g. temperature, humidity, luminosity, presence, notifications...

Feel free to implement a luminosity control (planned but not realized yet)


Why RPi?


  • The RPi can use up to 26 GPIO pins directly without an additional port expander or shift register. Most smaller/cheaper controllers do not have enough pins to drive the 20 LEDs directly.
  • The RPi has a built in current limiter on the GPIO pins. Resistors in line to LEDs are not necessary.
  • The RPi Zero has onboard WiFi to get the correct time via NTP. No external RTC is needed.
  • The RPi Zero has sufficient power and pins to run additional IoT features.
  • Faster and easier development and code change.


  • Linux! Many steps to setup the controller. See chapter on GitHub Wiki...
  • Linux! Potential security leaks to your local network.
  • Over 30 sec. boot time.
  • A little more expensive (about 20 Euro incl. MicroSD) than an ESP8266 (<7 Euro). Note also that an ESP8266 needs additional shift registers...

Why pigpio-lib?


  • This lib can handle software PWM for ALL 26 GPIOs without glitches.
  • Faster than BCM-lib.
  • Development and debugging can be done on your PC, remote-controlling the RPi GPIOs over the network.
  • Implementation for several programming languages available.


  • pigpio-deamon eats 7...10 percent of CPU time continously, independent of how many GPIOs or PWMs are active.
  • The lib's documentation leaves room for improvement.

  • 1 × Raspberry Pi Zero W
  • 1 × MicroSD Card with Raspian, Python, pigpio-lib and clock program
  • 20 × LEDs any Color you like. Max 3.1 Volt
  • 1 × 5V Power Supply e.g. Mobile Phone Charger with Micro-USB Cable

  • 1

    In this example I used LASER-cut plywood with a veneer layer and bend cuts.

    For this housing I used 2-k-epoxy-glue for the LEDs and wood-glue to 'freeze' the bend cuts.

    Feel free to use any kind of material and technique for your housing.

  • 2

    The BCD coding uses 4 LEDs for the second digit and 3 LEDs for the first digit. In the 12-hour configuration. The hours are also displayed with 4 LEDs.

    For 24-hour configuration the hours are also used 2 digits as minutes/seconds.

    The layout can be horizontal (like this example) or vertical. The second digit LEDs can be aligned in a row or between the first digit LEDs. Feel free to experiment with your design.

    Example A:

    Example B:

    Example C:

  • 3

    Solder all cathodes (short leg, minus) of the LEDs together and connect them to GND. Solder the anodes (long leg, plus) of the LEDs to the corresponding pin on the RPi (see pinout). Resistors are not necessary.

View all 6 instructions

Enjoy this project?



Mark wrote 01/02/2022 at 18:31 point

Brilliant project, I have been looking for a while... Many thanks for sharing.

  Are you sure? yes | no

Dillon Nichols wrote 09/11/2018 at 15:12 point

I was just thinking this morning that I want to replace the control board on my store-bought binary clock ( because I have to reset it every time the power goes out. I might use this project as the controller. Thanks for sharing!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates