The Joker Clock is a not any standard clock. Yes, it tells the time making use of the Pimoroni Micro Dot pHAT LED Matrix Display which displays the time and various animations in a lovely neon green glow. However, at random moments in time the Joker shouts out classic 'Joker style' quotes to scare anyone who may be around or trying to tell the time. Then the clock display returns and it is, just a clock again.
Micro Dot pHATThe project uses the Pimoroni Micro Dot which can be purchased here.
and is really easy to fit and install. The great point about pHATs is that they are designed to fit perfectly on the Raspberry Pi GPIO pins but also, they are the exact size of the Lego Alarm clock module.
In the terminal window, type the code:
curl https://get.pimoroni.com/microdotphat | bash
Once installed there are a number of starter programs to get you up and running, you can also read more about the code here.
The BuildOff with his head! Then simply strip the Joker down and remove the wires and components. Several of the plastic supports need to be removed, time to get the Dremel out and Dremel away to make way for the pHAT.
The Pi Zero W is perfect for this project as it has both WiFi and Bluetooth. The WiFi is mainly used to keep the clock time update but is also useful, as the Lego clock is a sealed unit so to update the OS or the code you can use SSH or VNC connections.
Bluetooth is used to connect and stream to a speaker which means that the Joker's phrases can be loud. It also overcomes the issue of trying to embed a speaker into the Lego clock when there is no space.
The original Lego clock has an ON / OFF switch in the back, this is removed and then made slightly larger so that the mico:USB cable can be passed through. The other end can be connected to a USB Battery or USB plug and power the project. Using a right angled USB cable enables the pHAT to sit flushed with the size of the housing.
The CodeThe program code is fairly simple. It uses the datetime function in Python to read the current time form the Pi OS. This is then converted into a string and each element is split into a single symbol that is then displayed on the LED matrix.
Next the program uses the random function to select a random number. This number is used to trigger the Joker shouting out. If the random number is less than 10 then one of twelve phrases is selected. These are saved in a file as MP3 recordings.
The Pi uses MPG321 to play the MP3 file, which is transmitted to a Bluetooth speaker, the volume is nice and loud to give anyone bystanders a fright!
Then the program iterates again and updates and displays the current time. A random number is selected and checked to see if it triggers a Joker phrase.
A crontab is used to make the program run when the Pi is booted up, this makes the Joker 'standalone' with no need for a monitor.<
Comments
Please log in or sign up to comment.