*** If you like this instructable please push vote button above for this project in the "Microcontroller Contest" ***

Build an interactive Pac-Man bedside clock, with a touch screen, and animated Pac-Man figures.

This cool project is surprisingly simple to make and is a great gift for those nostalgic Pac-Man addicts.

As well as being able to interact with the Pac-Man game, you can record a sound of your choice for the alarm.

Note: Ms Pac-man option can now be enabled in the setup menu!

Step 1: Gather the Materials

The Retro Pac-Man Clock is made from 5 key modules along with a case that is laser cut from MDF wood.

  1. Arduino Board - Arduino Mega 2560 R3
  2. Real Time Clock module - DS3231 RTC
  3. Touch Screen - 3.2" TFT LCD Display + Touch Screen for Arduino's Mega 2560 (*Note: Avoid Sainsmart see section 4 below)
  4. Touch Screen Arduino Shield - 3.2 inch Mega Touch LCD Expansion Board Shield
  5. Voice Recorder Module - ISD1820 Voice Recorder

Enclosed in the instructable is the necessary Arduino code, links to libraries and any special graphics files you will need to build the project.

In the list above there are links to suppliers of parts that are similar to the items used in the prototype. You are free to source the parts from wherever you see fit to ensure costs are minimized.

In addition to these modules, you will require the following components

  1. Panel Pins x 4 for fastening front case to body
  2. Two Part Epoxy Resin for gluing case together
  3. Sandpaper sheets - 4 sheets each of fine and medium grade for sanding wood
  4. Electric Drill with 3mm diameter wood drill bit.
  5. USB Cable 1m length
  6. USB charger (used for the power supply for the clock)
  7. 150mm x 30mm x 3mm MDF or Styrene to build a bracket to hold circuit in place within case
  8. Hot glue gun

Optional Auto Back Light Dimming Components only required if a Bedside Clock

  1. Resistor 270k Ohm
  2. Zener Diode 3.3v 0.5 watt
  3. Resistor 47 Ohm
  4. Light Dependent Resistor (LDR)

Step 2: Build the Case

The case is made from 9mm and 3mm MDF wood which has been laser cut to shape. Below are files with the dimensions and number of parts required that you can send to a local laser cutter company to do this for you.

1. Front Panel

The front panel is sandwiched between two side rings and glued into place with 5-minute two-part epoxy glue. Be careful not to overdo the glue as it will show if it oozes out the sides.

In addition to this, a small piece of material is glued over the front cover grill to provide a nice effect and also allow the alarm speaker sound to carry out the front of the clock.

Four Panel Pins have been inserted into the corners of the inside of the front panel and glued into place with approx 10mm protruding back into the case. This will be inserted into the back panel so that it can be removed during testing.

2. Back Panel

The back panel consists of five side rings followed by the back case which is sandwiched by the final side ring. Once again and glued into place with 5-minute two-part epoxy glue. Be careful not to overdo the glue as it will show if it oozes out the sides.

Using the hole positions from the front panel pins carefully mark and drill 3mm holes and check the front and back units connect together.

3. Sand and Paint Components
Once you have the front and back units assembled you can choose to paint any colour or just sand lightly by hand and cover with a clear lacquer spray. I chose the latter because I quite liked the stressed wood effect that the laser cutter left after a light sanding. I had to put 3 to 4 coats of clear lacquer spray on the wood to get it sealed as the wood is very porous.

Step 3: Assemble the Electronic Modules

The overall circuit contains a Real Time Clock, Arduino Mega, Sound Module, Touch Screen and a Screen Sheild.

1. Real Time Clock

Mount the Realtime clock on the back of the Arduino Mega as in the picture provided. I used a hot glue gun and packing foam to ensure they are not touching and there is some cushioning to absorb movement. In my case, I soldered 2 of the RTC legs directly to the Arduino and used hookup wire to connect 5v and GND to the Arduino.

2. Sound Recording Module

These are really cool and easy to use. In a similar fashion as above, use foam and hot glue to position the module and the speaker on the back of the Arduino taking care to ensure they are insulated from touching. The Sound Module is triggered by D8 on the Arduino, so this and the power supply need connecting as per the circuit diagram provided.

3. Auto Backlight Dimmer (Optional)
If you intend on using as a bedside clock, then you will likely want to automatically dim the backlight at night so it doesn't affect your sleep. (If not then you can skip this step!)

Unfortunately, the backlight in the TFT screen is hard wired into +3.3v and cannot be adjusted with the Arduino. This means we have to disconnect it and reconnect to a PWM pin on the Arduino to control the Backlight brightness. I wanted to do this with minimal damage to pins or tracks on the components so took the following approach.

Follow the steps below carefully

(a) To achieve this a Light Dependent Resistor (LDR) is positioned at the back of the unit to detect the light. Drill two 3mm holes in the case and push the LDR legs through the holes. Use hot glue on the inside of the cabinet to hold the legs in place. Solder two wires on the inside of the case and connect them as per the circuit diagram. Add a 270k Ohm Resistor to A7 of the Arduino as per the circuit diagram.

(b) Remove the TFT Display, and place it on a firm surface. Identify pin 19 (LED_A) and carefully remove a few millimeters of the plastic at the base of the pin. Bend the pin flat and away from the connector as per the picture above. Check that the TFT Sheild can plug in snugly and that the bent pin does not obstruct the plug or socket.

(c) Solder a 47 Ohm register to the bent over the pin and connect a wire from the resistor to D9 of the Arduino Mega. The Arduino D9 pin can sink up to 40mA so the resistor limits this to less than this. Attach a 3.3v Zener Diode to the same pin (LED_A) and connect this to earth as per the diagram. This purpose of this is to protect the backlight from overvoltage as it will regulate the voltage to 3.3v.

4. TFT Screen and Arduino Shield
Carefully push the 3.2' TFT Touch Screen connectors into the TFT Arduino Shield. Then carefully connect to the top of the Arduino as per the picture provided. The RTC has a battery so will retain the correct time even if power has been removed. The Alarm time is stored in Eeprom on the Arduino which means it will be retained if there is a powercut.

Step 4: Upload the Code and Test the Clock

The Project will require the following files and libraries to be loaded before it will compile and run. The code is unique and built around the capability of the libraries, the hardware, some custom graphics and other projects that I've borrowed from.

Please Note: Development of the code for this project has used IDE v1.06 and some of the required libraries are dated. This means some people are having issues with the new IDE version 1.6 and above when loading code. Therefore in the interests of simplicity, I recommend people use IDE v1.06 and have included the correct version library files in zip files at the bottom of step 4 of the instructable.

1. Arduino IDE

I have been using an earlier version of the Arduino IDE, therefore in the interests of simplicity, I recommend that you download Arduino IDE version 1.06 on your desktop machine before you install the code. You can get his version from here.

2. Libraries

These need to be downloaded and added to the IDE (Integrated Development Environment) that runs on your computer, used to write and upload computer code to the physical board.

  • UTFT.h and URtouch.h located in zip file below
  • Time.h located in zip file below
  • DS1307RTC.h located in zip file below
  • Wire.h and EEPROM.h are already included in IDE V1.06

Credit for UTFT.h and URtouch.h goes to Rinky-Dink Electronics I've included these zip files as it appears the source Website is down.

4. TFT Screen Variations

The vagueries of TFT screens and manufacturers have led to these notes.

(a) Sainsmart - People who have purchased a 3.2' TFT screen that is branded Sainsmart on the back of the TFT device have found they have to modify libraries to resolve display issues. My advice is to avoid these and purchase the same type as displayed in the instructable parts list. If you have purchased a Sainsmart TFT Display already there is a fix below

Edit the file "initlcd.h" and modify the following line from




You will need to restart the IDE and then reload the code to the Arduino.

(b.) TFT Controller Chipset - People who have purchased a 3.2" TFT screen may find they could also have one of two different chipsets "SSD1289" or "ILI9341"

The annoying thing is that its not easy to distinguish the difference online. The good news is that its easy to fix. If you get a blank screen after loading the code then its probably because its a ILI9341 controller. To fix you need to make the following changes to the code.

Edit the code and modify the following line of code from

UTFT myGLCD(SSD1289,38,39,40,41); //Parameters should be adjusted to your Display/Schield model


UTFT myGLCD(ILI9341_16,38,39,40,41); //Parameters should be adjusted to your Display/Schield model

Now try reloading the code to the Arduino.

5. Graphics Files

There are a group of bitmap files that I have included below that need to sit in the same subdirectory as the Arduino code when you begin to load into the Arduino. Therefore download the 17 files below and use the IDE to load.

6. Setup the Clock

Once the code has loaded successfully press the center of the screen and this should bring up the setup screen.

Use the menu to set the time and the alarm in 24 hour format.

Press the SAVE button to store the setting.

The RTC has a battery so will retain the correct time even if power has been removed. The Alarm time is stored in Eeprom which means it will be retained if there is a powercut.

7. Testing the Alarm

The Sound module is used to provide the Alarm. The ISD1820 is controlled by the Arduino D8 pin. Sound can be easily added by playing sound into the microphone while simultaneously pushing the record button on the ISD1820. In my case, I recorded the original Pac-Man introduction music from a audio file played through another device.

Once the sound is recorded the recording can be tested by pushing the PLAY-E button which should play the sound through the speaker.

Use the setup menu to set the clock time and the alarm time a few minutes apart. Be sure to "SET" the alarm and push the "SAVE" menu buttons. Once back to the main screen the Alarm should sound when the time occurs.

Turning off the Alarm can be done by pressing the center of the touch screen panel resulting in the Setup Screen.

8. Interacting with the game

The game has been designed to roughly emulate the original rules. The rules are as follows

  • Pac-man can be changed to Ms Pac-man by tapping the Pac-man icon in the setup menu
  • If Pac-Man eats a fruit the Ghost turns blue and can be eaten to score points
  • If Ghost is red and touches Pac-Man then Ghost gets points
  • The user can interact with Pac-Man by touching the LHS, RHS, Top Middle or Bottom Middle of the touch screen to issue commands. Pac-Man will only respond to a direction to go in the opposite direction to the way of travel. i.e if going left can be told to go right. If there is enough interest in the project I can add all directions later.
  • Every minute the fruit resets and any characters that have been eliminated are returned to the game.
  • Game scores reset at 95

When left alone the characters battle out the scores by randomly wandering through the maze. It's fun to watch and interact.

Step 5: Putting It All Together!

1. Adding External Power

The final step is to add the external power. Using a drill bit, add a hole in the back of the cabinet. Thread the USB cable through the back panel and then attach the USB cable VCC, GND, D+ and D- wires to the base of the Arduino USB Connector as per the circuit diagram. This has two advantages, firstly the USB input to Arduino Mega Boards has over current protection, and secondly you can use the USB cable to upload code changes without having to dismantle the box.

Hot glue the power cable insulation to the back of the Arduino to provide protection from cable tension when assembling front and back panels.

Add a cord grip to the cable by placing a cable tie tightly around the cable on the inside of the case on the power cable 6-8 cm from the Arduino connection. The cable tie should avoid tension on the joints when the USB cable is pulled by butting up against the inside of the case.

2. Mounting the Electronics in the case

Using 3mm thick Styrene or MDF cut out two brackets that are 105mm width x 12mm height. Cut a section out 95mm x 6 mm as per picture above.

Place the Circuit on top of the front panel and power on the circuit so you can see the front panel screen, Carefully position the brackets and screen in position and glue into place with Hot Glue.

Carefully do one bracket corner at a time and check the orientation and position of the screen. Let each glue joint cool before moving onto the next.

The outcome is a snug fit with a straight screen which is centered in the cutout hole.

3. Final Assembly

Gently push the Front Panel onto the Back Panel taking care to align the panel pins with each hole and gently pulling the USB power cord to take up the slack in the back panel. The cord grip is useful here and should protect any damage to wiring.

Plug into the USB charger and you're good to go. Enjoy!!

<p>TechKiwiGadgets great project and thanks for share. I build clock <br>and I have one queston regarding time. Is it possible ti show 24 hour <br>time instead 12 hour (am/pm).</p><p>Thanks in advance and best regards.</p><p>Robert</p>
<p>hi </p><p>Nice work. Please post a picture so we can see the result. Yes the code can be modified to show 24 hours time. I will add that to the list of suggested enhancements and if a few more ask for it I'll include.</p><p>Ps. Do me a favour and press the vote Button at top of instructable screen for this instructable in the microcontroller contest!!</p>
<p>hi,<br> manny thanks for reply. I already voted in contest.<br>Also I try to change sketch for showing 24 hour time format. Now i testing this change and for now is ok.<br>Also i will make 2 clock. One with your design, and one like old pacman cabinet game. When I finish I will post photos.</p><p>Best regards.</p>
<p>nice work!! Looking forward to see the pics of the pacman cabinet style. Great idea </p>
<p>Hello, Can I connect the screen directly to the Arduino Mega? remove the Expansion board shield? Thanks</p>
<p>The display works at 3v and the Arduino at 5v so the screen will end up being damaged. However you can do so if you use resisters to drop the voltage. The problem is it creates a whole lot of wiring and soldering so thats why I recommend the shield.</p>
<p>I found this tft that I think its perfect for the retro pacman clock... no need for shield, it has level shifting chips on it already and plugs directly on the ATmega2560: <a href="http://www.ebay.com/itm/272219211370" rel="nofollow">http://www.ebay.com/itm/272219211370</a></p><p>It even breaks out some unused pins! :)</p>
<p>I have found the solution for the touch portion, use this library</p><p>https://github.com/adafruit/Touch-Screen-Library</p><p>with these DEFINES</p><p>//Portrait</p><p>#define YP A2 //</p><p>#define XM A3 // X=0, Y=0,</p><p>#define YM A0 // Bottom left hand corner</p><p>#define XP A1 //</p><p>//Landscape</p><p>//#define YP A3 // </p><p>//#define XM A0 // X=0, Y=0,</p><p>//#define YM A1 // Bottom left hand corner</p><p>//#define XP A2 // </p>
<p>I have this screen and the screen works well but so for I can't get the touch to work and can't find any info on the screen.</p><p>They sent me the UTFT library but say they have no other info.</p><p>Any help would be much appricated.</p>
<p>Have you been able to locate any documentation or pinout or even model number for this display? I was trying to determine if there was a way to accomplish the backlight dimming for this display, but have no documentation to go off of.</p>
This one got different resolution. Are you able to adjust the code? Is so please share. Thanks.
Thats the plan, as soon i have revised code for the larger screen working I'll share it on thingiverse remix files, follow that for updates as soon its ready. :)<br><br>http://www.thingiverse.com/thing:2183736
<p>sounds like its worth checking out</p>
Thank you! I'm glad I asked...
<p>hello</p><p>Thank you for your work, it's great.</p><p>I have everything installed, the display works (ILI9341), but the touch screen does not work.</p><p>I checked the wiring, the only thing I did not put is the zener and resistance.</p><p>I did not put the ldr.</p><p>I changed the library for the ILI9341 because I had the white screen.</p><p>Can you help me to make the touchscreen work.</p><p>thank you</p><p>thank you</p>
<p>Did you run the URTouch_Calibration sketch in the examples and update the URTouchCD.h file.</p><p>I had trouble till I did this step.</p>
<p>I've tested with URTouch_Calibration sketch, the result is :</p><p>first line 0000000</p><p>second line 00000000</p><p>third line is always the same value, i've testing 15 x at different point off the screen and always same result</p><p>i think that my touch screen is ko</p>
Couple things to try.<br><br>1. Check there are no physical wires/connections to D0-D7 on the Arduino or TFT shield. I had a problem with one unit where D3 had been used on a previous project which is the interrupt pin for Touch screen.<br>2. Remove Che TFT shield and check if pins are clean and not bent.<br>3. Remove external power. Try a few different USB ports to power Arduino.
I had trouble too making the touch work, when i had it plugged in a computer usb port. When i used a wall usb charger the touch works fine.<br><br>Must be the voltage issue, PC usb is 4.95v while wall usb chargers are 5.2v
<p>i've tested with external power supply 9 v on black power connector.</p><p>don't work</p>
<p>Nice work, well done!! </p><p>Sure thing happy to help.Others have used this model with no issues.</p><p>Just out of interest pull the USB port out and push back in to reset the hardware. </p><p>Ive noticed after a code load sometimes the touch screen doesn't initiate.</p><p>If there are still issues direct message me and I will help out.</p><p>TechKiwi</p>
<p>I just finished my clock in black. (Notice the Ms Pacman.)</p>
Looks good! I wonder if anyone will try a yellow color case :)
<p>Nice work looks awesome. Great case</p>
<p>are you <strong>kidding</strong>?? a pea-brain like me would sit there watching this <em><strong>cool clock</strong></em> <em>all day</em>, drooling! <strong>x^D</strong></p>
<p>Ha Ha I know what you mean :)</p>
Note: Pac-man can be changed to Ms Pac-man by tapping the Pac-man icon in the setup menu !!
While using the Arduino IDE version 1.8.2 I experienced the same library issues as mentioned in the instructions. To get around this I substituted Time.h with TimeLib.h (from the Time-master library package) and got a clean compile.
<p>Cool thanks for letting me know. I'll try out and then and modify instructable. Please post a picture of your clock when you have it completed :)</p>
<p>I think the AM PM is off it is 12:12 and still showing AM I think it should be PM, at least that is what my computer says :-)</p>
<p>V7 code now available with AM/PM fixed</p>
<p>thanks well spotted. Will fix today.</p>
<p>Hi, I have an issue with the SSD1289 screen I just received. It looks like its skipping vertical lines or shifting them on the edges of letters or objects... See photo. Any suggestions? </p><p>Also the contrast and the color quality totally sucks compared to the other screen I have (ILI9481, res 480x320), another reason I'll put effort to resize the code to the larger resolution screen when I get a chance. </p><p>Another issue I got was trying to fit the larger screen in the case, I had to file down the edges of the PCB that hold the SSD1289 screen to fit in place! Sure they used much extra PCB area around that screen!</p>
<p>hi looks like the same problem raised by another maker and they resolved by applying this fix <a href="http://forum.arduino.cc/index.php?topic=435709.msg3002646#msg3002646">http://forum.arduino.cc/index.php?topic=435709.msg...</a></p><p>Can you message me the exact model numbers of the shield and tft display as I think it's something to do with sainsmart variants.</p>
<p>I'll try it, thanks. Still doesnt fix the bad contrast and color quality of SSDxxxx LCDs. the ILIxxxx models are way better! See the next video where I attached a 2.8 inch ILI9341 SPI screen from Adafruit (Slow screen but works):</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/Das2O3PHCMM" width="500"></iframe></p>
<p>hey just a thought. There is a delay in the main loop sketch to slow down the redraw of characters. Try reducing this on the ILI9341 and see if its addresses speed issue. </p>
<p>I removed that small delay, but didn't fix much. I suppose the SPI interface is still too slow for this animation of both sprites. Also the code freezes as soon as I replace the URtouch with the Adafruit capacitive touch library, must be a conflict between the UTFT and the I2C FT6206 driver. I'll give it another try later but not sure if it will be resolved. As far as I know all the ILI9341 screen I seen are SPI interface and up to 2.8inch, haven't see any 16-bit parallel versions of this screen except the larger resolution ILI9481 screens (480x320). So I'm not really sure if the &quot;Industry Park 3.2 TFT ILI9341 from Amazon is really an ILI9341.</p>
<p>Yes, the Industry Park 3.2&quot; TFT from Amazon is truly a ILI9341 16 bit parallel screen. I have one and it works great. in the Arduino program you have to ajust this line</p><p>UTFT myGLCD(ILI9341_16,38,39,40,41); //Parameters should be adjusted to your Display/Schield model </p>
<p>Is it this one? <a href="https://www.amazon.com/Industry-Park-Display-Module-Arduino/dp/B01LXVOS0V/ref=sr_1_1?ie=UTF8&qid=1491389268&sr=8-1&keywords=Industry+Park+3.2%22+TFT" rel="nofollow">https://www.amazon.com/Industry-Park-Display-Modul...</a></p><p>It looks exactly the same as the SSD1289 that I have on front/back marking... hmm.</p>
<p>yes it is. But the back actualy looks like this.</p>
<p>also it is 320 x 240 resolution</p>
<p>Cool could you please post a picture of the final result as would like to see how it looks!</p>
<p>This is the Industry Park screen. It is a little brighter than the SainSmart screen. the photos don't quite do it justice!</p><p>I tried it with both but decided to go with this one as I didn't need to alter the library except for the calibration.</p><p>Also I used Arduino 1.80 IDE with the Time library v1.5 by Michael Margolis</p>
<p>nice work thanks for photos</p>
<p>Oups, I take that back. The screen ILI9341 screen I use is in Shield form for arduino and only SPI: <a href="https://www.adafruit.com/product/1947" rel="nofollow">https://www.adafruit.com/product/1947</a> </p><p>But I also have this one that can be driven in 8-bit parallel mode! Much faster! <a href="https://www.adafruit.com/product/2090" rel="nofollow">https://www.adafruit.com/product/2090</a></p><p>Now If only could get the I2C touch driver to work as well... :)</p>
<p>I believe the delay is due to the I2C vs parallel interface not the controller. I have a Industry Park 3.2&quot; TFT ILI9341 (from Amazon) and it is just as fast as the SSD1289 display.</p>
<p>Good point quite likely the issue - paralell vs serial thruput makes sense. The Industry Park display looks like the same model I have used. I think the key here is avoiding the Sainsmart display</p>
Thanks I'll check into that, and share updated code as this ili9341screen has I2C touch controller (adafruit capacitive screen)
<p>Read the review by YM</p><p><a href="https://www.amazon.com/SainSmart-3-2-Inch-SSD1289-Arduino-Raspberry/dp/B008FWSG3S/ref=sr_1_1?ie=UTF8&qid=1490993982&sr=8-1&keywords=ssd1289" rel="nofollow">https://www.amazon.com/SainSmart-3-2-Inch-SSD1289-...</a></p><p>and yes, this is the fix I found that fixed it, there are some smart people around!!!!</p><p><a href="http://forum.arduino.cc/index.php?topic=435709.msg3002646#msg3002646" rel="nofollow">http://forum.arduino.cc/index.php?topic=435709.msg...</a></p><p>I'm going to use screens with the ILI9341 controller and not the SSD1289 going forward.</p><p>Now I have a problem.</p><p>Once the alarm is set I can't get back into the setup screen until either the alarm has go off or I de-power and re-power the clock </p>
<p>Hi, Try the latest version of code. This was an earlier bug that was fixed. Let me know if any probs.</p>

About This Instructable




Bio: Crazy about technology and the possibilities it can bring. I love the challenge of building unique things. My goal is to make technology fun, relevant ... More »
More by TechKiwiGadgets:Retro Pac-Man Clock Interactive LED Shoes - Arduino Personalised Word Clock With Animated Time Transitions 
Add instructable to: