Introduction

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!

The clock has lots of different display modes to choose from:

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.

Parts List

2 x Sure Electronics 2416 LED Matrix panels These are 24×16 pixels and come in red or green with 3 or 5mm LEDs. Make sure you get the version based on the Holtek HT1632C driver chip. People have found other displays with the HT1632C chip that work too such as this one. But you may need to flip the image in software. (Details for how to do this are at the end of this article.)

1 x Arduino Uno / Duemilanove / Dicecimila with ATmega 328 CPU

1 x DS1307 or DS3231 real time clock chip and IC socket

1 x Crystal oscillator for the DS1307 / DS3231

1 x 3.3v coin cell battery and battery holder for the DS1307 / DS3231

1 x Arduino prototyping shield

1 x Breadboard and jumper wire for testing (or if you don’t want to solder)

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.

Alternatively a number of users have made very cool PCB’s for the entire clock that do away with the need for the Arduino and prototyping shield. You basically build an Arduino and clock all on one board. To get hold of them mail:

Kevin: pongclock@kevinbinder.co.uk Sells boards for £6, which is donated to Cancer Research.

Gary: gazman@gazman321.co.uk

Gary’s custom PCB on the left, Kevin’s on the right.

Parts in Detail

Sure 2416 LED Matrices

You can get these from eBay or Sure online for around $20 each in red or green with 3mm or 5mm LEDs. My clock in the video is made with the 3mm green displays. Some people have had success with other boards based on the HT1632C driver chip, if you are lucky it will work straight off, or you may need to flip the display in software. The displays use a serial protocol called SPI to receive data.

Sure 2416 LED Matrix with HT1632C.

1 x Arduino Uno / Duemilanove / Dicecimila with ATmega 328 CPU

The Arduino microprocessor runs the clock software, plus has inputs and outputs we connect to the displays, buttons and clock chip to. Ensure you get an Arduino with the ATmega 328 CPU. You can get Arduino’s for about $30. Try places like Adafruit, Sparkfun Electronics, Cool Components, Seeed Studio or eBay.

Arduino ‘Diecimila’ with ATmega 328 CPU.

Arduino Prototyping Shield and Header pins

The prototyping board or ‘shield’ plugs on 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, as we’ll need this for the clock chip. I.e.the board has an area that brings each pin of the chip 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 so it can plug into the 2 rows of sockets on 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 anyhow.

DS1307/DS3231 Real Time Clock (RTC) chip, Crystal, 3.3v Coin Cell Battery & Holder

The clock chip keeps time, regulated by the crystal. It uses something called the I2C protocol (pronounced “I squared C”) and only needs 2 wires to send time data to the Arduino. 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.

16 Pin IDC Socket

The Sure 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.

‘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. Any buttons will do, I got these ones that mount on the shield.

USB Lead – Type “A to B”

This is needed to to program the Arduino, and then as a power lead for the clock.

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.

Circuit diagram

This is how it’s all connected…. not too difficult.

Pong Clock Schematic

IMPORTANT!

Due to my crappy skils at diagrams the schematic above is missing 2 things:

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’ll be fine.

Connecting it up

LED Displays

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. 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 – they are wired 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. If your displays light up the wrong way round, just swap their identities using these switches.

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.

A display with dip switch set as number 1.

Clock Chip

Connect pins 5 and 6 from the DS1307/DS3231 to Arduino pins A4 and A5.

Connect the crystal between pins 1 and 2 on the DS1307/DS3231. 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 clock chip 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. I’ve had reports of people saying their clock doesn’t tick, only to find out they have omitted the battery, so don’t skip this!

Push Buttons

Connect one push button between Arduino digital input pin 2 and GND, the other between Arduino digital input pin 3 and GND.

Power

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 word of caution with the power: Don’t use a higher voltage supply into the Arduino’s round power jack. The Arduino’s onboard regulator will not be able to cope with the power demand the displays draw. If you try you’ll notice the Arduino will get very hot very quickly and probably not last too long!

Also be very careful if you are powering the clock from your computer’s USB port for testing. 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!

Prototyping shield

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.6.5. Later versions may not work. 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 from my page on GitHub by clicking the “Download Zip” button bottom right.



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 main clock code appear in the window. Now pick your Arduino Board Type in the Tools -> Board menu. Then hit the Verify – the check mark icon. This tests the code and should compile 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 should spring to life. Use the buttons to set the time and then sit back and admire your handiwork!

Troubleshooting / Flipping the Display

Help, my display is back to front / upside-down!

Normally this means you are using a different brand of LED matrix that is wired differently. If you find everything is reversed (numbers backwards etc) you need to add a couple of lines to tweak the code.

Load up the main pong code in the Arduino IDE. Search for this line:

void ht1632_plot (char x, char y, char val) {

This is the function that plots points on the display. If your display is upside-down add the following just below:

y = 15-y;

Or if your display is back to front add:

x = 47-x;

Or add both lines if you display is both back to front and upside-down. Finally find the line in the code that starts:

byte get_shadowram (byte x, byte y) {

And add the same changes just underneath that line too.

I get an error compiling

Check the libraries are installed in the correct folder and appear in the libraries menu

Make sure you have restarted the Arduino IDE after adding the libraries.

Check you are using Arduino software version 1.6.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

Often 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 or the displays are the wrong way around

Check the DIP switch settings on the displays are as per the instructions – one set to CS1 and the other CS2. If the displays are the wrong way around, change the display set to CS2 to CS1 and the other from CS1 to CS2.

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 very old Sure LED Displays

The old LED displays from Sure used 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:

#include <ht1632c.h>

and change it to…

#include <ht1632.h>

Then verify and upload the code as per the instructions above.

French version of Pong Clock with Space Invaders, Sleep Mode & more!

Thanks to Matock who has taken my original pong code and done some more awesome stuff with it, including extra modes like space invaders and a sleep timer. He’s also translated the text to French. If you want an English version you’ll need to ask him nicely in the comments to change bits back! See below for the full list of his changes and a download link:

* French translation with French accented letters

* adding the Invaders mode based on the work of Richard Shipman on the Wolf’s Spoor blog

* adding a “Special Event” function to display a welcome message every 15 min on specific days (ex: New Year Day, Christmas, etc…, cf. is_special_event() function)

* adding a sleep mode defined in a setup sub-menu with sleep and wake-up hours, to reduce the power consumption during the night (<70mA for Arduino Uno)

* setup data are persistent (stored in the EEPROM memory)

* refactoring of the code (reorganisation, clean unnecessary variables, maximum use of const, optimisation of variable memory space)

* some fixes (array sizes, stack overflows, mistypes…)

Matock’s version is called 5.1FR. Here is his download link.



Thanks…

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, Matock for the updates & Kirby Heintzelman for all the testing!