Introduction: Pi Zero Binary Clock
I’ve had a Unicorn pHAT sitting in a box for a while, but I finally used it in a simple project. Because it has four rows of LEDs, I thought it would be ideal to make a binary clock from.
Step 1: Electronics
The electronics involved in this project are limited and practically plug-and-play: A Raspberry Pi Zero and a Unicorn pHAT. The main twist here, is that instead of soldering a set of regular headers on the Pi, I used a set of right angle headers, resulting in the pHAT facing forward rather than up.
Step 2: Software & Code
The code for this project is very straightforward. It takes the time, converts it to binary and displays it on the LED matrix. By editing the code, you can change the color of the LEDs.
Code on github. Download the script and save it on your Pi.
Some other things need to be configured properly as well:
* time zone: pi@binaryclock:~ $ sudo cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime
* unicorn phat: pi@binaryclock:~ $ curl -sS get.pimoroni.com/unicornhat | bash
* run at startup: pi@binaryclock:~ $ sudo crontab -e
# m h dom mon dow command
@reboot sudo /home/pi/binary.py
Step 3: Enclosure
The enclosure consists of two elements: a white acrylic body and two wooden end caps. The acrylic hides the electronics, while still allowing the light of the LEDs to shine through.
The end caps were carved using a CNC, and the edges rounded using a router, though similar results could be achieved by cutting small blocks with a saw.
The acrylic strip was cut from a bigger sheet. By scoring a straight line with a sharp knife, it's possible to snap the sheet along the line. Using a small torch, heat was applied to the strip to make it fold along the heated line.
Step 4: Assembly
With the enclosure parts ready, the electronics can be fitted inside. I used a strip of double sided tape to attach the Pi Zero to the acrylic. To ensure the LEDs remain as close as possible to the acrylic, hot glue was used to hold them in place.
Once the electronics were fitted, the wooden end caps were mounted on the sides. As the connectors remain accessible at the back, power can easily be applied.
Step 5: Video
That's it, this is how I built this binary clock using a Raspberry Pi Zero and Unicorn pHAT. If you would like to see the building process in a more dynamic way, check out the video!