March 2014 Update!
Version 5.1 of the firmware is out. It contains bug fixes and some sweet lower case font action. NOTE: If you upgrade, please replace all 4 libraries as well as the main code.
BTW, if anyone fancies designing a case for this let me know!
This clock uses the classic video game Pong to tell the time. The 2 players automatically win and lose so their scores show the hours and minutes. It’s not too hard to build and should cost less than £60 / $100. All the parts are easily available on eBay and the software code is free to download. Features of firmware 5.1 include:
- Pong Clock
- Large Digits
- Time written in words, e.g. “Ten Past Twelve”
- Time and date with seconds
- Time and date with seconds and a slide effect
- Time and date with seconds and a jumbled character effect
- Date display with printed retro flashing cursor effect
- 12/24 hour option
- Brightness option
- Random clock mode option (changes the display mode every few hours)
- Daylight saving option to add an extra hour
- Push button driven menus for setup & display selection.
The project uses 2 bright LED matrix panels from Sure Electronics. You can choose between green or red panels with 3mm or 5mm LED’s . An Arduino runs the main code and a DS1307 clock chip keeps time, even when the power is off.
- 2 x Sure Electronics 2416 LED Matrix (24×16 pixels) in Red or Green (Make sure you get the version based on the HT1632C and not the HT1632 – more detail below).
- 1 x Arduino Duemilanove / Uno with ATmega 328 CPU
- 1 x DS1307 real time clock chip and IC socket
- 1 x Crystal oscillator for the DS1307
- 1 x 3.3v coin cell battery and battery holder for the DS1307
- 1 x Arduino prototyping shield
- 1 x Breadboard and jumper wire for testing or if you don’t want to solder (optional)
- 1 x 16 Pin IDC Socket for the display connection
- 2 x Push to make buttons
- 1 x USB Lead
- 1 x Mains to USB power adapter
Plus wire, solder, tools, time, sweat, tears, etc.
Parts in Detail
2 x Sure 2416 LED Matrix You can get these from eBay for around $20 each You can buy either the red or green display, and with 3mm or 5mm LEDs. My clock in the video is made with the 3mm green displays. Make sure you get the newer version of the display which is based on the Holtek HT1632C chip. You can tell the newer displays as they have the controller chip and DIP switches on the back. The front is relatively empty of components as you can see:
1 x Arduino Uno / Duemilanove / Dicecimila with ATmega 328 CPU. The Arduino is the brains of the clock. It has a microprocessor that runs the clock software, plus inputs and outputs we connect to the displays, buttons and clock chip. Ensure you get an Arduino with the ATmega 328 CPU. The Uno is the latest version and has one as standard. Some Duemilanove / Dicecimila boards come with the ATmega 168 CPU with doesn’t have enough RAM for the clock code. You can get Arduino’s for about $30. Try Sparkfun Electronics or eBay.
1 x Arduino Prototyping Shield and Header pins. The prototyping board or ‘shield’ plugs onto the top of the Arduino making it easy to add other components. It brings the Arduino’s input and output pins onto a circuit board that you can solder things to. Get a board which is designed for a chip to go on, i.e. one that brings each pin of the IC out to a solder pad you can connect wires to. (You can see this area on the bottom left of the board in the picture below.)
Again places like Sparkfun or eBay are good sources for them. You should be able to pick one up for $15 – $20. Check you get the black header pins too as some boards are sold without them. These are the pins that you solder to the edges of the board that plug into the rows of sockets each side of the Arduino.
If you don’t like the idea of soldering, you could get a breadboard and jumper wire to build the circuit on temporarily instead. This is a good idea anyway to test it’s all working.
1 x DS1307 Real Time Clock (RTC) chip, Crystal, 3.3v Coin Cell Battery & Holder. The clock chip keeps time, regulated by the crystal. The battery powers the chip if the clock is unplugged, so it remembers the time when you turn it back on. I found all these bits on eBay bundled as a kit for $10.
1x 16 Pin IDC Socket. The display panels come with ribbon cable that needs to connect to a socket like this. We’ll solder it to the shield so we can plug the display ribbon cable in. They are a couple of dollars on eBay. If you aren’t planning to solder, you don’t need this.
2 x ‘Push to Make’ Buttons. These are used to set the time / change the display mode. You can get a pack on eBay for a dollar or two.
1 x USB Lead – Type “A to B”
This is needed to to program the Arduino, and then as a power lead for the clock.
1x Mains to USB Power Adapter
This is used to power the clock and you can pick them up for less than $10. Look for one with an output of 150mA or above.
This is how it’s all connected…. not too difficult.
Due to my crappy skils at diagrams the schematic above is a bit off.
- The 2 push buttons are not shown in the above diagram. You will need to connect one button between Arduino digital pin 2 and GND. The other button needs to go between Arduino digital pin 3 and GND.
- The pin layout on the DS1307 is not exact. Pin 8 should really be top right opposite pin 1. All the pin numbers are correct in terms of what they connect to however, so follow the pin numbering and you should be fine.
Connecting it up!
The displays use a serial protocol called SPI to receive data. There are only 4 wires needed between the Arduino and the first LED display. Two more wires are required for power.
You’ll notice each display has 2 connectors on the back. These are for daisy chaining multiple units together as we are doing, and it’s what the little ribbon cable in the box is for. Connect the displays together using the ribbon cable. You can use either connector on the back as they are the same.
Use one of the free connectors on either display to connect to the Arduino. Again it doesn’t matter which one. For testing purposes I poked jumper wires from the Arduino into the ribbon cable connector. When I was happy things were working, I soldered the IDC socket to the prototype shield, meaning I could plug the ribbon cable in.
As on the wiring diagram, Pins 4 and 5 on the Arduino need to connect to pins 1 and 2 on the display connector respectively. These are used for something called Cable Select or ‘CS’. Cable Select determines which display listens when the Arduino is sending data out. The displays have small DIP switches to set their cable select address – essentially giving them different identities. Set one display’s switch to have CS1 on , and the other to have CS2 on .
Pin 10 on the Arduino is used to send the actual display data, and connects to pin 7 on the display. Pin 11 on the Arduino sends a clock signal. Connect this to pin 5 on the display.
Finally connect pin 12 on the display connector to positive and pin 11 to GND. Alternatively if you prefer you can use the screw terminals on the back of the display for power.
The DS1307 clock chip keeps the time. It uses something called the I2C protocol and only needs 2 wires to send time data to the Arduino. Connect pins 5 and 6 from the DS1307 to Arduino pins A4 and A5.
Connect the crystal between pins 1 and 2 on the DS1307. The crystal regulates the clock and can be connected either way round.
Finally the coin cell battery’s positive terminal connects to pin 3 on the DS1307 and the negative terminal connects to GND . The battery runs the clock chip if the power is turned off meaning you don’t have to reset the time. It should last for many years.
Connect one push button between Arduino digital input pin 2 and GND, the other between Arduino digital input pin 3 and GND.
We’ll supply power in using the USB port on the Arduino and then connect everything to the Arduino’s 5v and GND pins. Connect the 5v pin from the Arduino to the 5v pins on the display and DS1307. Then connect the GND pin from the Arduino to GND pins on the display and DS1307.
A FEW WORDS OF CAUTION WITH THE POWER…
Don’t use a higher voltage supply into the Arduino’s round power jack. The Arduino’s onboard regulator may not be able to cope with the power demand. If you try you’ll notice the Arduino will get very hot very quickly and probably not last too long!
Be very careful if you are powering the Arduino from a computer’s USB port. You could easily damage the port if you have a connection wrong or if the computer can’t supply enough juice. I powered my setup with my Macbook for testing and all was well, but be warned!
The prototyping shield plugs into the Arduino making it easy to add components. On a standard prototyping board you should have room to solder the DS1307 clock, crystal, battery, buttons and the IDC socket for the display ribbon cable.
I can’t really give instructions for what to solder where, as prototyping boards vary quite a bit depending on what you buy, but you should be able to figure it out based on the circuit diagram.
When things are soldered it should look something like mine in the picture. You can see the IDC plug on the left for the display cable, in the middle is the DS1307 clock chip. The tiny silver capsule below the chip is the crystal. On the right is the coin cell. Below that are the 2 push buttons for setting the mode and time. The red button is a reset button which came in the pack with the shield. It’s useful as the shield covers up the reset button on the Arduino itself.
Below you see everything connected together. The 2 displays plug into the prototyping board which sits on top of the Arduino. Nearly done!
Uploading the Clock Code
The last job is to upload the clock code to the Arduino. First you’ll need to download the Arduino programming software called the Arduino IDE. The current clock code was tested with IDE version 1.0.5. You can download the IDE from Arduino’s site here: http://arduino.cc/en/Main/Software
Once the IDE is installed, download the clock code here.
Unzip the clock code zip file. Inside you will see the main clock sketch called pongclock5_1.ino and 4 library folders called ‘Button’, ‘RTClib’, ‘Font’ and ‘ht1632c’. These libraries are extra bits of code needed by the main clock sketch.
Next install the libraries. When you installed the Arduino software it should have created a folder somewhere for your sketches (projects) to go in. Find that folder and see if there is a folder called libraries inside. If there isn’t, create one. Then copy the 4 library folders from the zip file into the libraries folder. After you have done that quit and restart the Arduino IDE to make it pick up the new libraries.
After restarting, go to the Sketch -> Import Library menu. If the libraries are in the right place you should see their 4 names listed in this menu.
Now go to the File menu and open the main pongclock sketch – the file ending in .ino. You should see the code appear in the main window. Next pick your Arduino Board Type in the Tools -> Board menu. Then hit the Verify (check mark) icon. This tests the code and should compete without errors. If you do get errors here, you’ve most likely not got the 4 libraries in the right place.
OK, time to upload the code to your Arduino! Unplug the Arduino from the clock prototyping shield and plug it into your computer with the USB cable. Click upload and wait for the code to be uploaded. Watch the TX and RX LED’s on the Arduino flash for signs of data transfer.
Finally unplug the Arduino from the computer and plug it back into the prototyping shield and displays. Then plug the USB lead from the Arduino into the mains to USB adapter.
All being well the display’s should spring to life. Well done! Use the buttons to set the time and then sit back and admire your handiwork!
And if you really, really like the project, here’s my bitcoin address!
I get an error compiling:
- Check the libraries are installed in the correct folder and appear in the menu
- Make sure you have restarted the Arduino IDE after adding the libraries.
- Check you are using Arduino software version 1.0.5.
I get an error uploading to the Arduino:
- Check your board type and serial settings are correct in the Tools menu.
- Check your Arduino has 32K RAM or more.
The clock doesn’t change:
- Normally a wiring issue. Check the LED on Pin 13 of the Arduino flashes. If not then the clock chip is not being read. Check your connections to the DS1307.
- Connect the clock to a computer running the Arduino IDE. Click the serial console button and set it to 57600 baud. You should see the time being printed to the console if the clock is being read. Check the wiring as above if it’s not.
- You must have the coin cell battery connected for the clock to work.
The displays don’t light up
- Check your wiring to the ribbon cables and check the display is getting enough power.
- Try another power supply.
- Remove one display and see if you get half the screen. If you do, then most likely not enough power is being supplied.
The 2 displays show the same half of the clock
- Check the DIP switch settings on the displays are as per the instructions.
The text display is garbled after upgrading to 5.1
- Make sure you have replaced the font.h library file with the new one in the 5.1 download.
If you have the older Sure LED Displays
The older LED displays from Sure use a different type of LED driver chip called the Holtek HT1632. You can tell these displays as they have the chips on the front of the LED board. If you have these, you need to replace the ht1632c.h library file in the normal clock code download with this file. Quit and relaunch the Arduino IDE to pick up the new file, then load up the main pong clock .ino sketch file. Next look for this line near the top of the code:
and change it to…
Then verify and upload the code as in the instructions.
Thanks to everyone who contributed, including WestFW on the Arduino forum for providing the initial LED driver code, SuperTech-IT over at Instructibles, Alexandre Suter for help with the conversion to Arduino 1.0, Richard Shipman for the lower case font & Kirby Heintzelman for all the testing!