Home > Microcontroller >Comprehensive Circuits > Make an Interactive Arcade Bedside Clock

Make an Interactive Arcade Bedside Clock

Source: InternetPublisher:jikai233 Keywords: Alarm clock interactive DIY design Updated: 2024/12/17

Make an Interactive Arcade Bedside Clock

It's an interactive arcade bedside clock with a touch screen and animated arcade characters, and you can record an alarm sound of your choice.

The program includes a 3D printed case and four standalone programs to choose from.

Arcade Clock - DK Mario, Space Invaders and Pac-Man animations

Pacman Clock - An interactive animated Pac-Man game with a clock function

DK Clock - An interactive animated DK game with a clock function

Tumble Ghost - Animated Pac-Man ghost game based on Flappy Bird

It's fun to make and makes a great gift for anyone who loves to relive the nostalgia of 80's arcade game characters.

Step 1: Gather Materials

pYYBAGK5eiOAZrvPAARZ_Y6K_qw318.png

Arduino Board - Arduino Mega 2560

Touch Screen Arduino Shield - 3.2" Mega Touch LCD Shield Shield

Touch Screen - 3.2” TFT LCD Display + Touch Screen for Arduino Mega 2560

Real Time Clock Module - DS3231 RTC

Recorder Module-ISD1820 Recorder

PLA Filament for 3D Printers

Two-part epoxy for bonding the enclosure together

USB cable 2m long USB charger (for power supply of clock)

Hot glue gun

Cable Ties X 3

The optional automatic backlight dimming component is only required in the case of a bedside clock:

Resistor 270k ohm

Zener diode 3.3v

0.5W resistor 47 ohm

Light Dependent Resistor (LDR)

Step 2: Print the 3D enclosure

You can find my 3D printable enclosure files here.

Step 3: Build the Circuit

pYYBAGK5eh-ABKvIAAMbwYzr08Y209.png

The entire circuit contains the Real Time Clock, Arduino Mega, Sound Module, Touch Screen and Screen Shield.

Real-time clock

poYBAGK5ehyAcKmHAAPGhoHsM9I734.png

Mount the Real Time Clock on the back of the Arduino Mega as shown. I used a hot glue gun and packing foam to make sure they didn't touch and had some cushioning to absorb movement. In my case I soldered the 2 RTC legs directly to the Arduino and used hookup wires to connect the 5v and GND to the Arduino.

pYYBAGK5eheAJVcOAAOfJnkqnTs851.png

Recording module

These are really cool and easy to use. In a similar manner to above, place the module and speaker on the back of the Arduino using foam and hot glue, taking care to ensure they are insulated from contact. The sound module is triggered by D8 on the Arduino, so this and the power supply need to be connected as per the circuit diagram provided.

Automatic backlight dimmer (optional)

poYBAGK5ehSAJRZFAAK9T9bYEUY140.png

If you intend to use this as a bedside clock then you may want to automatically dim the backlight at night so it doesn't disturb your sleep. (If not then you can skip this step!) Unfortunately the backlight in the TFT screen is hardwired to +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 the pins or tracks on the component so took the following approach. Please follow the steps below carefully:

(a) To achieve this, a light dependent resistor (LDR) is placed on the back of the unit to detect light. Drill two 3mm holes in the enclosure and pass the LDR legs through the holes. Use hot glue inside the enclosure to secure the legs in place. Solder two wires inside the enclosure and connect them as per the circuit diagram. Add a 270k ohm resistor to A7 of the Arduino as per the circuit diagram.

poYBAGK5ehCADFA5AAJuyRLB0qU125.png

(b) Remove the TFT Sheild and place it on a solid surface. Identify pin 19 (LED_A) and carefully remove a few millimeters of plastic from the bottom of the pin. Bend the pin away from the connector as shown above. Check that the TFT Sheild can be inserted tightly and that the bent pin does not obstruct the plug or socket.

(c) Solder a 47 ohm resistor to the bent pins and run a wire from the resistor to D9 of the Arduino Mega. The Arduino D9 pin can sink up to 40mA so the resistor limits it to less than this. Connect a 3.3v zener diode to the same pin (LED_A) and connect it to ground as per the diagram. The purpose of this is to protect the backlight from overvoltage as it regulates the voltage to 3.3v.

TFT Screen and Arduino Shield

Carefully push the 3.2' TFT Touchscreen connector into the TFT Arduino Shield. Then carefully connect to the top of the Arduino as per the pictures provided. The RTC has a battery so it will keep the correct time even if the power is lost. The alarm time is stored in the Eeprom on the Arduino, which means it will be retained if the power is lost.

Step 4: Load the code

The project will require the following files and libraries to be loaded before it can be compiled and run. The code is unique and built around libraries, hardware, some custom graphics, and functionality from other projects that I have borrowed.

Please note: The code for this project was developed using IDE v1.06, and some of the required libraries are outdated. This means that some people have had issues loading the code with new IDE versions 1.6 and above. So, for simplicity, I recommend people use IDE v1.06 and include the correct versions of the library files in the zip file at the bottom of step 4 of the tutorial.

Arduino IDE

I have been using an earlier version of the Arduino IDE, so for simplicity, I recommend that you download Arduino IDE version 1.06 on your desktop before installing the code. You can get his version from here.

TFT screen changes

The TFT screen and the manufacturer's ambiguity lead to these considerations.

(a) Sainsmart - If you have purchased a 3.2" TFT screen with Sainsmart branding on the back of the device, you will find that they have had to modify the library to fix the display issue. If you have purchased a Sainsmart TFT display, there is a fix below

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

LCD_Write_COM_DATA(0x01, 0x2B3F);

to

LCD_Write_COM_DATA(0x01, 0x3B3F);

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 that they may also have one of two different chipsets "SSD1289" or "ILI9341" and annoyingly it's not easy to tell the difference online. The good news is it's easily fixable. If you get a blank screen after loading the code, it's probably because it's an ILI9341 controller.

To fix, you need to make the following changes to your code. Edit the code and modify the following line of code

from

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

to

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

Now try reloading the code to the Arduino.

(c.) Inverted touch screen control

Some manufacturers have reported that the Y axis touch screen buttons are inverted. A fix for this has been determined where there are two lines of code to change to flip the touch screen readings.

Find: “yT = myTouch.getY();” Change it to: “yT = 240 - myTouch.getY();”

Don't forget to search twice, the first instance is to control pacman in clock mode, the second is in the settings menu.

Graphics Files

When you start loading into the Arduino, I have included a set of bitmap files below, they need to be in the same subdirectory as the Arduino code. So download the following files and load them up using the IDE.

Set the clock

Once the code has been successfully loaded, press the center of the screen, this should bring up the setup screen. Use the menu to set the time and alarm in 24 hour format. Press the SAVE button to save the settings. The RTC has a battery so it will keep the correct time even if power is lost. The alarm time is stored in the EEPROM, which means it will be retained if power is lost.

Test 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 a sound into the microphone while pressing the record button on the ISD1820. In my case, I recorded the original Pac-Man intro music from an audio file played from another device. After recording the sound, the recording can be tested by pressing the PLAY-E button, which should play the sound through the speaker. Use the settings menu to set the clock time and the alarm time to a few minutes apart. Be sure to "Set" the alarm and press the "Save" menu button. Once you return to the home screen, the alarm should sound when the time comes. The alarm can be turned off by pressing the center of the touch screen panel to get to the settings screen.

Touchscreen calibration

Some manufacturers have found that the buttons on the setup screens do not align with the TFT touch controls. In these cases, the touchscreen requires calibration. This can be easily done by using the touchscreen calibration code and instructions provided in the URtouch library. If you find this issue, follow these instructions.

Four different programs to choose from

1. Arcade Clock - DK Mario, Space Invaders and Pac-Man animations 2. Pacman Clock - Interactive animated Pacman/Ms Pacman game with clock function

3. DK Clock - An interactive animated DK game with a clock function

4. Tumble Ghost - Pacman Ghost animation game based on Flappy Bird

Step 5: Putting It All Together

poYBAGK5egeAYoXVAAQJmoP4UEQ038.png

Adding external power

The last step is to add the external power supply. Using a drill, add a hole in the back of the enclosure. Feed the USB cable through the back panel and then connect 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 benefits, firstly the USB inputs to the Arduino Mega Boards have overcurrent protection and secondly you can use the USB cable to upload code changes without disassembling the box. Hot glue the power cable insulation to the back of the Arduino to prevent strain on the cable when assembling the front and back panels. On the power cable 6-8 cm from the Arduino connection, add a wire clamp to the cable by placing a cable tie tightly around the cable on the inside of the enclosure.

Mounting Electronics in the Chassis

Place the circuit on top of the front panel with the four hole guides which should center the screen over the cutouts. Power on the circuit so you can see the front panel screen, check that the screen image is in the correct position, then glue it in place with hot glue. The result is a tight fit with a square screen centered in the cutout holes.

Final Assembly

Gently push the front panel onto the rear panel, then gently pull on the USB power cable to take up any slack in the rear panel. A cable clip is useful here to protect any damage to the wiring. Plug in a USB charger and you're good to go.

pYYBAGK5egSAZnrlAAbxic-pCIg481.png

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号