Pong Clock

79,499

495

108

March 2014 Update! Version 5.1 of the code is out with bug fixes and a nice lower case font. Get it while it's hot! The link is on the last page of this instructable!


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 $100. All the parts are easily available on eBay and the software code is free to download!

The clock can also show the time written in words such as "Ten Past Twelve", with large or small digits and with a slide or jumble effect. The date pops up every now and again too, printed out with a retro flashing cursor effect. A menu screen lets you choose the display mode, or you can have the clock pick a random mode every few hours.

The project uses 2 bright LED matrix panels fromSure Electronics. You can buy them in red or green with either 3mm or 5mm LEDs. An Arduinoruns the main code and a DS1307 clock chip keeps time, even when the power is off.

Step 1: Parts List & Cost

So here's what you need...

2 x Model 2416 Red or Green LED Matrix Displays from Sure Electronics

You can get these from Sure's eBay store for $15 each: http://www.sure-electronics.net/ Make sure you get the new version of the display which is based on the Holtek HT1632C chip. You can tell the new displays as they have the controller chip and DIP switches on the back. (See pic). My clock is made with the 3mm LED display, but they also make a larger 5mm one.

1 x Arduino Uno / Duemilanove with ATmega 328 CPU

Th Arduino is the brains of the clock. It has a microprocessor that runs the main clock software, plus inputs and outputs we connect to the displays and other components. Ensure you get an Arduino with the ATmega 328 CPU. (Some older boards come with the ATmega 168 with doesn't have enough RAM). You can get Arduino's for about $30. Try Sparkfun Electronics or eBay.

1 x DS1307 Real Time Clock chip (RTC) and IC socket.
1 x Crystal Oscillator for the DS1307
1x 3.3v Coin Cell and holder - battery backup for the DS1307

I found all these bits on eBay bundled as a kit for $10.

1x Arduino Prototyping Shield

The prototyping board or ‘shield’ plugs onto the top of the Arduino making it easy to add components. It brings all the Arduino's input and output pins onto a circuit board that you can solder components 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 (see pic). Again places like Sparkfun or eBay are good sources for them. You should be able to pick one up for $15 - $20. If you don't like the idea of soldering, you could get a breadboard and jumper wire to build the circuit on temporarily instead.

1x 16 Pin IDC Socket
We solder this socket to the prototype board 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.

2x ‘Push to Make’ Buttons.
These are used to set the time / change the display mode. You can get them for a few dollars.

1x 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.


Step 2: Circuit Diagram

This diagram shows how to connect the parts. It's not too difficult, and you can try it on a breadboard first to make sure all is working. When you are happy you can solder the parts to the prototype shield.

IMPORTANT NOTES!

1)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 digital pins are the ones that don't start with the letter 'A'.

2) The pin layout on the DS1307 on the diagram 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 numbering and you should be fine.


Step 3: Connecting the Displays

The displays use a serial protocol called SPI to receive data. There are only 4 wires needed between the Arduino and the first LEDdisplay. 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, 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. When I was happy things were working, I soldered the IDC socket to the prototype shield, meaning I could plug the ribbon cable in.


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.




Step 4: Connecting the Clock Chip

The DS1307 clock chip keeps the time. It uses 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.


Step 5: Connecting the Buttons

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


Step 6: Connecting the Power Supply

Connect the 5v and GND lines from the displays to the Arduino’s 5v and GND pins. Do the same for the 5v and GND pins from the DS1307 clock chip. We are going to supply power via the Arduino's USB port using a mains to USB adaptor.

A FEW WORDS OF CAUTION WITH THE POWER!

1) Don’t use a higher voltage supply into the Arduino’s round power jack. The 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!

2) 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! Use the USB adapter anytime the displays are plugged in to be safe.

Step 7: About the Prototyping Board

The Prototyping boards or ‘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 and the IDC socket for the display ribbon cable. I attached the 2 buttons with wire, but you could solder them direct to the board.

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 right for the display cable, in the middle is the DS1307 clock chip. The tiny silver capsule above the chip is the crystal. On the left is the coin cell to keep the time if the power is lost. The red button top right on the board 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.

Step 8: All Connected!

Here you see everything connected together. The 2 displays plug into the prototyping board which sits on top of the Arduino. Easy!



Step 9: Uploading the Clock Code

The last job is to upload the clock code. First you'll need to download the Arduino programming software, called the Arduino 'IDE'. This code was tested with version Arduino version 1.0.5. You can download it from here:
http://www.arduino.cc/en/Main/software

Once that's installed, download the zip fie containing the clock code from Dropbox here: https://www.dropbox.com/s/mh8qzsms8gl3f34/pongclock5.1.zip

Unzip the file. Inside you will see themain clock sketchcalled pongclock5_0.ino and 4 library folderscalled '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 (i.e. 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 into this libraries folder. After you have done that make sure you 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. It ends 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. The compile test should compete without errors.

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. Then plug the USB lead from the Arduino into the USB to mains adapter.

All being well the display's should spring to life. Use the buttons to set the time and then sit back and admire your handiwork!


And if you really like the project you can tip me in bitcoin to this address! 1JPdDk4DiKYDsjTYghHatJp1FFQsv6bpEv


Troubleshooting
I get an error compiling:
  • Check the libraries are installed and appear in the menu.
  • Check you have Arduino software version 1.0.5.
I get an error uploading to the Arduino:
  • Check your board type and serial are set correctly in the Tools menu.
  • Check your arduno has 32K RAM or more.
The clock doesn’t change:
  • Normally a wiring issue. Check the LED on Pin 13 or the Arduino flashes. If not then the clock chip is not being read. Check your connections to the DS1307.
  • You must have a battery connected for the DS1307 to work.
The displays don’t light up
  • Check your wiring to the ribbon cables and check the display is getting enough power.
The 2 displays show the same half of the clock
  • Check the DIP switch settings on the displays are as per the instructions.

Thanks
Thanks to everyone who contributed, including WestFW on the Arduino forum for providing the initial driver code, SuperTech-IT for the dimming and 12 hour mode, Alexandre Suter for help with the conversion to Arduino 1.0 & Kirby Heintzelman for all the testing!






Clocks Challenge

Runner Up in the
Clocks Challenge

5 People Made This Project!

Recommendations

  • Make it Glow Contest 2018

    Make it Glow Contest 2018
  • First Time Author

    First Time Author
  • PCB Contest

    PCB Contest

108 Discussions

0
None
mrnick1234567Neanderthul

Reply 11 months ago

Yeah those look like they would work. You will need a battery for the clock. The pin numbers may be different to what I have in the instructable though so you would need to figure out what is what in them

0
None
Neanderthulmrnick1234567

Reply 10 months ago

Any idea how I will be choosing the correct CS options on the Adafruit panels? These panels don't have the switches on them like the Sure Electronics ones do.

0
None
mrnick1234567Neanderthul

Reply 10 months ago

Hmm, they seem to say you just fill solder jumper j5. But you would need to check what their code is doing to see if it's the same. To be certain of it working buy the displays i mention in the instructable.

0
None
ClaudeS12

2 years ago

Hi folk

a question , you can't play (Pong ) it's playing automatically ?

claude

1 reply
0
None
germapClaudeS12

Reply 2 years ago

It plays automatically and every minute a player looses to reflect a change in the clock. Clever!

0
None
goldenshuttle

2 years ago

thumbs up both hands indeed. Will this work if I use digispark USB attiny 85 ?

0
None
StuartS9

3 years ago

Hi again.

Worked it all out for myself.

Works great.

Stuart Smith

0
None
JGlielmi

3 years ago

Hello, I was wondering if this clock can be made using a 32 X 64 RGB LED Matrix Board such as can be purchased from AdaFruit? it would make the display portion easier and construction simpler.

0
None
StuartS9

3 years ago

Hi there. I have built this clock. It works great apart from not being able to set the time and change any of the controls. As the curser will not move using the two buttons. It will go through all of the menus. It just will not allow me to move the curser in order to choose a menu. Hence; Unable to move into settings?

Please could you advise me on what to do. I am using version 1.0.5 and a cheap uno board. And I am using a pre-built DS3231 RTC AT24C32 12C Precision Real Time Clock & Memory Module. (Bought off ebay) Does this RTC need extra software. It does keep the time on the pong board? There is nothing wrong when I verify the software and it uploads without any problems.

I thank you for your time.

Stuart Smith.

0
None
paulindallas

4 years ago on Introduction

Saw your project and just HAD to do it.

Got all the parts and downloaded the most recent code (Nov. 2013) to run
with the Arduino 1.05 software.

Loaded the four libraries and when I went to compile I get the following
error:

error: 'myfont' was not declared in this scope.

The Font library is in libraries so am kind of lost.

Running the Arduino with a PC.

Any help would be appreciated.

Thanks, Paul

6 replies
0
None
tomoloblapaulindallas

Reply 4 years ago on Introduction

I just got the same errors trying to verify the code. I opened the font library file and declared myfont, tinyfont and bigfont constant, by adding const between unsigned and int.

Hope I could help.

0
None
kivalotomolobla

Reply 3 years ago on Introduction

Just wanted to chime in and say I was having the same problem and adding "const" for all three and it seems to work like a charm! Thanks!

0
None
Vaalixkivalo

Reply 3 years ago on Introduction

I;m sorry, could you explain where you went? my font code already has 'const' in it

0
None
kivaloVaalix

Reply 3 years ago on Introduction

I'm on my work computer so I don't have the edited library in front of me, but try this. Just add "const" to three of the lines. Find and change this:

unsigned char PROGMEM myfont[80][5] = {

to

unsigned const char PROGMEM myfont[80][5] = {

this

unsigned char PROGMEM mybigfont[10][20] = {

to

unsigned const char PROGMEM mybigfont[10][20] = {

and this

unsigned int PROGMEM mytinyfont[42][3] = {

to

unsigned const int PROGMEM mytinyfont[42][3] = {

I'm pretty sure this is what I did to get it to compile. I'm still pretty new to the programming so I hope this helps.

0
None
SuperTech-ITtomolobla

Reply 4 years ago on Introduction

Ya, this was all written on IDE 0023, and other IDE updates after tended to kinda puke on it...lol...

0
None
paulindallastomolobla

Reply 4 years ago on Introduction

Thanks... I went to the author's site and posted problems there. The solution that finally worked was to start with an empty "library" (rename the old library... old library or something) create a new "library" folder and import the 3 libraries that come with the program so that they are the only ones in there. After that it worked like a champ.

Glad you found another solution. I will keep that in mind for similar problems in the future.

0
None
Vaalix

3 years ago on Introduction

Hey, so i am going to build this (already have most of the parts.) but i have minimal experience with bread boards and doing this stuff. any Ideas where to go to learn? like videos?

0
None
sdandala

3 years ago on Introduction

Can someone help me to work with sure electronics 32x8 green led module to run as a simple clock.