Arduino Pong Clock With Temperature and Timer

6,626

108

5

Posted

Introduction: Arduino Pong Clock With Temperature and Timer

In Pong clock mode the 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 is based on a clock by Nick Hall.

This is the 2nd version of my clock and now displays temperature in slide mode and also has a timer in normal mode. The 1st version can be found here Pong Clock Mk1 instructable

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,

Options-12/24 hour option, Brightness option, Random clock mode option (changes the display mode between Slide with temp and Pong see bottom for details), 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.

Modifications to Nick Hall's clock

I have made the following changes to Nick's code/design.

I have removed one of the modes, Time and date with seconds with jumbled character effect to save space on the Arduino.

Instead of the DS1307 RTC I have used a DS3231 AT24C32 I2C Precision Real Time Clock Module.

A PIR is used to turn off the clock display when no one is in the room.

I have also added synchronisation to my Master Clock system if you don't use this feature then the clock accuracy will depend on your RTC module a DS3231 is far more accurate than a DS1307.

The completed clock has been fitted into a white wooden box with a black display mask printed on inkjet slide film.

Countdown timer added to Normal mode. When countdown is completed an alarm is sounded by playing any 48KHz mp3 file through a JQ6500 sound module

Large numbers of different alerts can be set along with volume from the control panel

Temperature display added to slide mode via an Adafruit MCP9808 High Accuracy I2C Temperature Sensor

The IR remote control is not used in this version but a control panel fitted to a modified mains switch plate is used instead

Random Mode
Random mode has been changed so only my favorite 2 modes Slide and Pong are displayed.

When Random mode is set Slide is displayed from 08:50 to 05:10 and then Pong from 05:10 to 08:50 e.g. 00:00 Slide until 05:10 then Pong until 08:50 then Slide until 15:10 then Slide until 18:50 then Pong until 25:10 etc etc. So when the 1st min digit is 8 and secs are 10 Slide mode is activated until the 1st mins digit is 5 and seconds are 10 Pong mode is activated. This means Slide mode is shown for 6 mins 20 seconds followed by Pong for 3 mins 20 seconds.

Step 1: Pong Clock MK2 Uses

The video shows the different modes of my Pong Clock.

Picture 1 shows the Pong Clock in a kitchen with the control panel hidden away in a cupboard.

Picture 2 shows the pong clock in a seating area with the control panel and PIR panel set into the wall in chrome flush mount boxes.

Step 2: Display Modes

Animation 01

This is the default mode and displays the time and temperature with sliding digits. The temperature is checked every 10 seconds.

Animation 02

This is the timer mode. When in another mode and the Timer/Start button is pressed the clock will jump to this mode. The timer loads with a preset time from code (4 mins as I use it for timing brewing tea). The time can be adjusted using the control panel. If the preset time is OK then press Timer/Start again to start the countdown timer.

On completion of the count down a sound is played and the display returns to the Time and Temperature display.

Animation 03

Pong Clock mode. The clock plays pong with itself missing the ball to update the time every minute.

The time is displayed as the game score.

Animation 04

Word clock mode. The time is displayed as words.

Animation 05

Big Digit clock. In this mode the time is displayed as large digits.

Step 3: Construction Case Preperation

  1. The case is made from a cheap White Wooden Jewellery Box obtained off ebay
  2. First scrape off the white lettering from the glass lid using your finger nail or a hard piece of plastic.
  3. Then carefully pull out the glued in wooden dividers making sure you do not split the case sides.
  4. Remove the felt ring holders and fit a board a new base board on top of the existing to hide the glued down lining.
  5. The old mortise slots are tidied up with filler
  6. A display mask is printed out on clear ink jet film
  7. The mask is attached behind the glass with thin wooden strips.
  8. Completed case ready for circuit boards.
  9. The base of the case is then sprayed black ready for final assembly of the electronics.

Step 4: Construction Mounting Boards/Displays in the Case

Pic 01

2 off 13x35mm timber battens are fixed across the box using countersunk No4 screws to hold the Sure dot matrix displays.

The top baton is about 23mm from the top of the inside of the case ( or the width of the RTC PCB). Just fix the top baton for now screw from the case sides to the end of the batons. The batons are adjusted up or down so the displays are up to but not touching the display mask. Leave a gap under the batons to allow for wiring.

Pic 02

Fix the main PCB to the base of the box using a couple of short screws leave it clear of the lower wooden baton.

Pic 03

The displays are mounted in the centre of the box foxed with M2 screws and sit on a wooden baton off cut fixed flush to the top of the lower baton. There is not a lot of space on the lower display PCBs so the off cut has to be cut to fit.

Pic 04

The RTC module fits snugly between the top baton and the case. Once the display is fixed to the top baton the position of the lower baton can be found. Fix in place with No4 countersunk screws from the sides of the case. Fix the temperature module in place with No2 screws then fit the LED board in place to align with the text on the display mask.

Pic 05

The lid has two thin timber strips attached by No2 screws to the underside. The glass side of the timber strips seen below are covered with double sided tape. The top strip the tape facing the glass is left on so it does not stick to the display mask but just cushions it in place. The lower strip has both sides of tape exposed. One side stick to the lower baton and the other is stuck to a piece of white paper cut to size. This provides the white background to the display mask text. The double sided tape is cut away around the slot in the lower baton but the paper covering is not cut to act as a diffuser for the LEDs.

The lower baton double sided tape is cut away around the LEDs then the whole strip is covered in white paper (not shown).

Pic 06

Rear view of the lid showing how the timber strips are attached to the lid.

Pic 07

With the lid shut and no mask fitted the timber strips are in place with double sided tape showing ready to be covered in white paper. Note the paper will cover the LEDs and act as a diffuser.

Pic 08

Display mask in place behind the glass held in place by the wooden batons. The white paper stuck to the double sided tape shows through the clear lettering on the display mask.

Step 5: Display Mask

Pic 01

The display mask is printed out onto clear inkjet transparency paper

Pic 02

The mask is cut to fit into the recess in the rear of the lid

Pic 03

Mask fitted in place

Pic 04

Thin strips of wood and tiny M2 wood screws hold the mask in place.
Double sided tape is fixed to the mask side of the tape and white paper is then cut to size and fixed to the tape to stop it sticking to the mask and to give a white background for the clear lettering of the mask.

The lower wooden strip of wood has a square section cutaway so the LEDs can illuminate the 3 pulse indicator lettering.
The strips of wood are cut/fixed so they clear the inside of the case when the lid is closed.

Step 6: Construction Control Panel

Pic 01

The control panel is made from a Polished Chrome 2-Gang Front Plate with a 4 Module Aperture fitted with a switch plate cut from a sheet of aluminium

Pic 02

The panel is fitted with PCB mount miniature push button switches. The blanking panel mount is removed but the plastic spacer remains to give a shadow edge around the switch panel.

Pic 03 -05

The switches are mounted onto Vero Board with 0.1" hole spacing so a template was drawn up in a CAD program set to inches rather than millimetres The cross points mark the hole positions for the 11 switch buttons

Pic 06

The template is fixed to an aluminium sheet that has been cut to fit the front plate. A centre punch is then used to mark the drilling points through the template

Pic 07

Holes are then drilled where marked

Pic 08

The panel is then labelled using Lazertran inkjet paper and 2 coats of Acrylic varnish applied

Pic 09

Mounting holes are drilled through the face plate and then marked onto the switch plate

Step 7: Construction PIR Panel

Pic 01

A PIR detector module is used to switch on the display when anyone is in the room. If no movement is detected in the room the display turns off to save power.

Pic 02

The PIR sensor is housed under the white diffuser.

Pic 03

The PIR module is fitted into a Polished Chrome 1-Gang Front Plate with Double Module Aperture fitted with 2 White Blanking Modules

Pic 04

The blanking modules clip into the front plate and have a hole drilled into them for the PIR diffuser

Pic 05

The blanking modules are fitted into the front plate to hold them secure during drilling The centre of the two blanking plates is marked and then pilot drilled A 22mm Forstner bit is then used to carefully drill the hole in the plastic plates To finish off a 24mm stepped drill bit is used to ream away the rear of the 22mm hole to allow a snug fit of the PIR diffuser.

Pic 06-07

Once the hole is drilled the blanking plates are removed, the raised edge at the back of the blanking panel will need cutting back/filling down and then any rough edges are finished off with a small file.

Pic 08-09

The PIR module diffuser is then pressed into the hole and held securely with hot melt glue The module is then clipped in place again finished off with a bit more hot melt glue.

Step 8: LED Panel

There are three LED indicators that sit behind the display mask. The LEDs shine through the white paper diffuser and light the corresponding word on the display mask.

Video

The 30 Sec LED lights on receipt of the 30 second pulse from a master clock at 00 seconds and 30 seconds. The 1 Sec LED lights on 1 second then goes out for the following second. The Sync LED only lights on receipt of the 30 Sec pulse when the clock has drifted out of sync with the master clock by a few mSecs. Once lit is indicates that the clock is now back in sync showing perfect time. The number of times the Sync LED lights depends on the accuracy of the RTC. The video shows Normal mode with timer running, the Red "Sync" LED lights on 30 seconds to show the clock was out of sync and is now back in sync with the Master clock

If you are not synchronizing to a Master Clock then LEDs D1 30 sec and D5 Sync along with their corresponding resistors can be omitted. The DS3231 is accurate to around 1 second a week at room temperature.

Step 9: Real Time Clock Modification

Modification of DS3231 AT24C32 I2C Precision Real Time Clock Module

My clock uses a DS3231 AT24C32 I2C Precision Real Time Clock Module instead of a DS1307. The module comes supplied with a Lithium-Ion rechargeable battery see diagram above. I use a non rechargeable battery so have removed resistor R5 from the module as below.

Pic 01 Location of R5 on the DS3231 module.

Pic 02 Charging Resistor R5 removed.

Step 10: JQ9500 Sound Module

Adding Sound to the Module

Plug the module pic 01 into your PC and run the file MusicDownloader.exe on the module.

Pic 02 Click on the 2nd tab then click on the button to the right of the black box Pic 03

Pic 04 A file requester will open. Select your sound files and click on Open

Pic 05 Go back to the first tab and click the button after a short delay the files will start to be copied

When complete you will get this message pic 06

Further info on this module can be found here JQ9500 info

Step 11: Adafruit MCP9808 High Accuracy I2C Temperature Sensor

This I2C digital temperature sensor is very accurate, with a typical accuracy of ±0.25°C over the sensor's -40°C to +125°C range and precision of +0.0625°C. They work great with any microcontroller using standard i2c. There are 3 address pins so you can connect up to 8 to a single I2C bus without address collisions. It also has a wide voltage range makes is usable with 2.7V to 5.5V logic!

Features

Simple I2C control

Up to 8 on a single I2C bus with adjustable address pins

0.25°C typical precision over -40°C to 125°C range (0.5°C guaranteed max from -20°C to 100°C)

0.0625°C resolution

2.7V to 5.5V power and logic voltage rangeOperating Current: 200 μA (typical)

Power Pins
VDD - This is the positive power and logic level pin. It can be 2.7-5.5VDC, so fine for use with 3 or 5V logic. Power VDD with whatever logic level you plan to use on the i2c lines.GND - this is the ground power and logic reference pin.

I2C Data Pins

SCL - this is the I2C clock pin. There's a 10K pull-up already on the board, so connect this directly to the i2c master clock pin on your microcontroller

SDA - this is the I2C data pin. There's a 10K pull-up already on the board, so connect this directly to the i2c master data pin on your microcontroller

Optional Pins These are pins you don't need to connect to unless you want to!

Alert - This is the interrupt/alert pin from the MCP9808. The chip has some capability to 'alert' you if the chip temperature goes above or below a set amount. This output can trigger to let you know. It is open collector so you need to use a pull-up resistor if you want to read signal from this pin.

A0 A1 A2 - These are the address select pins. Since you can only have one device with a given address on an i2c bus, there must be a way to adjust the address if you want to put more than one MCP9808 on a shared i2c bus. The A0/A1/A2 pins set the bottom three pins of the i2c address. There are pull-down resistors on the board so connect them to VDD to set the bits to '1'. They are read on power up, so de-power and re-power to reset the address

The default address is 0x18 and the address can be calculated by 'adding' the A0/A1/A2 to the base of 0x18

A0 sets the lowest bit with a value of 1, A1 sets the middle bit with a value of 2 and A2 sets the high bit with a value of 4. The final address is 0x18 + A2 + A1 + A0. So for example if A2 is tied to VDD and A0 is tied to VDD, the address is 0x18 + 4 + 1 = 0x1D.

If only A0 is tied to VDD, the address is 0x18 + 1 = 0x19

If only A1 is tied to VDD, the address is 0x18 + 2 = 0x1A

If only A2 is tied to VDD, the address is 0x18 + 4 = 0x1C

Full details on the Adafruit site.

Step 12: Dot Matrix Display

2416 Green LED 3mm Dot Matrix Display Information Board(DE-DP11111)

Don't forget to connect the extra power lead in and out of the display boards

Step 13: Vero Boards

Pic 01-02 main Veroboard

Pic 03 Control panel Veroboard

Pic 04-05 LED Veroboard

Step 14: Schematic

Pin connections are shown in pic 02

Pic 01 shows the schematic

I have uploaded the schematic as a zip file in case it can't be viewed clearly from your browser .

Step 15: Clock Operation

Setting the Timer

"Cancel" always returns to the default display mode

Press "Timer/Start" & default timer value is displayed

If you want to use the default value press "Timer/Start" again and the display will start to count down

If you want to set a new timer Press "Timer Down" to move down in 30 second steps or "Timer Up" to step up in 30 second steps

To start timer at displayed setting press "Timer/Start" again

Display brightness

Press "Disp Adj"

Brightness is displayed. Pressing "Timer Down" cycles the brightness value in steps up to min then max again

To set the displayed brightness press "Menu/Set"

Main menu

Press "Menu/Set" steps through the menu

The following menu options are displayed in rotation

Slide Clock

Pong Clock

Digits Clock

Word Clock

Timer Clock

Setup Menu

When you get to the menu option you want to select just wait and it will auto select

If Setup Menu is selected a further menu is displayed again in rotation

Go Back

Random

12/24

Set Clock

Disp Adjust

Setting the Time

Once set the time will only need changing for winter/summer time

Using the "Menu/Set" button step through the main menu and select "Setup Menu"

In the setup menu select "Set Clock" go through the menu using the "Timer Down" to adjust values then "Menu/Set"

When the final value is set the clock resets the seconds to 0.

Press the "Man Sync" button when the real seconds are nearing 30 seconds to set the clock seconds to 30.

If auto sync is in use the next time the sync pulse is received the clock seconds will be set exactly to 30 seconds.

Setting/Adjusting the timer alarm

The alarm sounds are stored as mp3 files on the sound module

Pressing "Play/Pause" will play or pause the current sound

While the sound is playing pressing and holding "Vol Up/Next" or Vol Dn/Prev" will turn the alarm volume up or down

Momentry pressing "Vol Up/Next" or Vol Dn/Prev" will play the next sound track on the sound module and set it as the alarm sound for the timer

Step 16: Code

Code v7.5 can be downloaded above and works with Arduino IDE Currently version 1.6.5

Tip: If you're installing on Windows and you have older versions of the IDE that you want to keep, choose the "Windows zip" file install.

Where possible I have marked my changes to the original code thus //Brett

Random Mode

Random mode has been changed changed so only my favorite 2 modes Slide and Pong are displayed. When Random mode is set Slide is displayed from 08:50 to 05:10 and then Pong from 05:10 to 08:50
e.g. 00:00 Slide until 05:10 then Pong until 08:50 then Slide until 15:10 then Slide until 18:50 then Pong until 25:10 etc etc. So when the 1st min digit is 8 and secs are 10 Slide mode is activated until the 1st mins digit is 5 and seconds are 10 Pong mode is activated. This means Slide mode is shown for 6 mins 20 seconds followed by Pong for 3 mins 20 seconds.

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Space Challenge

      Space Challenge
    • Science of Cooking

      Science of Cooking
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    4 Comments

    Nice Project but schematic connections are not clear to See. Could you share à İsis file?

    The schematic does not seem to show full size so have uploaded a the file as a zip.

    Hi Mehmet EFE not sure what a "à İsis" file is?

    Awesome project well done