Introduction: Make a Digital "meow" From Analog Clock
Is your analog clock just not doing enough stuff? Want to do digital things with an analog clock?
This tutorial will show you how to make a Kit Cat Clock play a “meow” sound clip, at precise time intervals, using the Atmega 328P-PU via the Arduino Uno development board. In my example, the meow will occur hourly. This doesn't have to be a Kit-Cat clock either, this idea may work with other clocks that use a magnet motor.
Assumptions (skip if you're already an expert in everything)
The project encompasses many intermediate to advanced skills such as burning a bootloader and soldering of wires. Therefore, some requisite knowledge and skills are needed before proceeding. I will assume that you know how, or will at least be prepared to do the following:
Burning a bootloader onto the Atmel328P-PU (unless yours already has one).
Uploading “sketches” onto the Atmel328P-PU via Arduino
Entering commands into a terminal emulator or command prompt (windows)
Using a soldering iron to make connections between components.
Possible usage of a drill or Dremel tool for trimming/cutting plastic parts, and boring holes.
Arduino Uno R3 x 1
Breadboard x 1
Jumper Wire (enough pieces)
350 Ohm x 1
150 Ohm x 1
220 Ohm x 1
280 Ohm x 1
10K Ohm x 1
330 Ohm x 1 (optional if you want the LED while using Arduino on Breadboard Setup)
100 uF x 1
10 uF x 1
22 pF x 2 (may be optional)
16 Mhz Crystal Oscillator
0.5 Watt small speaker (approximately 50.8 mm diameter) x 1
7.5 Volt AC wall adapter (I used the Vtech brand found at Toys R Us) x 1
7805 Voltage regulator x 1
Soldering Iron and Solder
Protoboard (or some other final project board that will be small enough to fit with the clock case)
Heat shrink (optional)
Hot Glue gun (optional)
Takane Quartz Clock (assuming you need to replace the default one inside Kit Cat, as I did)
Hall effect sensor x 1
I used the SS41 family of Hall effect sensors. These sensors are sensitive enough to detect the relatively weak magnetic field from the clock magnet motor. The specific one that I purchased may be found here
Step 1: General Project Overview:
An interesting aspect of this project is using analog devices (in this case an analog clock) to interact with the digital world of the Atmel 328P-PU. Arduino is probably one of the simplest ways to achieve this. I will be using the typical clock motor found inside the classic Kit Cat clocks to generate a digital pulse which will feed into the Atmel chip. The reason this will work is because the clock motor utilizes a permanent magnet, located within the proximity of a coil, to create the mechanical torque necessary to spin the clock hands. I will take advantage of this magnetic field by using a Hall Effect sensor to detect the magnetic flux from the clock motor. The sensor will output a digital HIGH whenever one of the poles from the magnet is facing the sensor, and then output a LOW when the opposite pole is near the sensor. This pole transition occurs every second, or has a frequency of 1 Hz and is the reason why this serves as an ideal motor for driving clock hands.
Note: the sensor isn't actually touching the magnet, it's just very close to it. The pictures show how close I was required to place the sensor, in order to get readings.
The pictures here show the inside of the actual clock and the magnet motor to the right side. The type of clock is called a "Takane Quartz" and they are pretty common in cheap analog clocks.
Once we have a steady pulse coming from the sensor, all sorts of things can be done digitally, and really it's only limited to your imagination on what you can do. In this tutorial I will simply make a counter that counts the clock pulses (from the Hall sensor), and upon finishing the count, then plays a “meow” audio clip.
The first step involves mounting the Hall sensor near enough to the magnet motor so that you can get a good reading. I had to place the sensor very close to my magnet motor to get an output. You can test the sensor by attaching something like an LED to the output pin of the sensor and then turn the clock on. If this works then the LED should blink every other second. This is because the output is only HIGH while one of the poles is facing the sensor (let's say the north pole as an example); when the opposite pole (south) is facing the sensor the output is LOW.
After you have determined an appropriate location and distance to get your readings, you should then begin thinking about how to mount it there permanently. I chose to use super glue to hold the sensor in place. I also considered the location because of where the back casing would be. I had to cut out a small rectangular hole so the sensor pins would be accessible. You should determine what works best because although these clocks are nearly the same, sometimes the layout is slightly different inside, and the placement of the sensor may vary depending on the particular clock that you have.
Step 2: Soldering Wire to the Input Pins of Sensor
Now it's time to solder the pins to wire. The reason I did this was for two reasons: First you want to be able to test the sensor as you continue working, and also because you will need those wires when you connect them onto your breadboard and finally the protoboard. Note, using different colored wire may make it easier when you need to quickly identify the pins. That's what I did.
Pinout configuration may be found at this site
Step 3: Preparing the Audio File
If you already know how to convert a .WAV file to a C file, then you can skip or skim through this step.
Now that the sensor is attached to the appropriate pins on the breadboard, you will need to upload the audio sketch onto the Atmel328P. But first, some modifications and “massaging” needs to be done first. This is where you could make some of your own modifications and I will go into some (but not all) of the detail regarding the use of Audacity and wav2c programs. You should go ahead and open the code that I've provided in your Arduino IDE. When you open the sketch in the Arduino IDE, the first tab is a slight alteration of the PCM audio sketch written by Michael Smith, the original may be found on the Arduino site:
Audacity is an audio editing program. It's very powerful and allows a .wav file to be exported as an 8-bit mono, unsigned .wav file. This is necessary to get the file size reduced and also to maximize the compatibility with the audio playback sketch. You may be able to work around different bit rates and sizes, but I haven't experimented with it. We will only be using the necessary features in Audacity to get the job done.
Wav2c, as the name implies, can convert a .wav file to a C file. This is also necessary because the .wav file by itself is too large to fit in the memory of the 328P-PU. As of this writing you can download the source code directly from github. You may also be able to get compiled versions from other websites. Either way, you should use it or another similar program for the conversion process.
Step 4: Using Audacity and Wav2c
The goal of the sound file conversion is to take an audio file (.wav) and transform it into a useful C header file document. This allows the arduino to use the information in the header file to be output as sound through a speaker.
-First open in the file in Audacity.
-Change the project rate to 8000 Hz (located in bottom left corner).
-Then select “tracks” from the menu and select “resample”.
-Next do a an export > other uncompressed files.
-Under options select 8-bit signed.
This will prepare the file for the next step below, which is conversion to C file.
-Next open a terminal and change to the same directory as the file.
-Run the following command (sox) to trim the tail (assuming there is one)
sox file.wav file-cut.wav trim 0 10000s
-Then run the final command to actually do the conversion
wav2c file-cut.wav file.h sounddata
(notice that a copy of the original file is actually being converted)
-Next, open the arduino IDE and add a new blank tab (the button for adding a new tab is on the far right of the Arduino IDE).
-Rename the tab to the same name as the header file.
-Copy and paste the contents into the tab
Step 5: Testing Your Sound
Now that you have the sounddata.h file ready, and you have verified the Arduino sketch, you should now upload it to your chip. I used the Arduino board directly for all of my initial tests, but then later used the "Arduino on Breadboard" configuration for my remaining test. I've attached the diagram here.
If all goes well, turn on your clock, and test it to make sure that it's counting the pulses from the clock and then delivering output. Note: when I originally did this, I set the audio playback counter for every 60 seconds so that I didn't need to wait an entire hour to see if it was working, then I later changed the counter to 3600 seconds or 1 hour). To change the meow interval, locate the piece of code near the last lines and find the clockCount variable. Change it to whatever value you want.
Step 6: Soldering Everything for a More Permanent, Compact Design
Now for the fun part...soldering all of the important parts from your breadboard to a more compact protoboard. You won't need everything like the LED output or reset button (assuming you had one from the Arduino on Breadboard circuit). There are much better ways to do this, but if you have limited supplies, protoboard is probably your best bet. Many people now are doing their own PCB etching and processing. If you can do that, then by all means do it, because it's much better than a protoboard.
You also need to connect your AC adapter to the positive and negative nodes of the protoboard where it meets the voltage regulator pins. I used the Vtech 7.5 volt model. These are about 10 bucks at Target, and 12 at Toys R Us. Or you may use anything similar that you have lying around the house. Caution: You should try to keep the voltage difference between the regulator and adapter to a minimum though, because it will heat up otherwise. If the difference is large, then you should put a heat sink on the regulator to help dissipate the heat. The voltage difference between the 7805 and the Vtech AC adapter is only 2.5 volts at 300mA, but you should still place a small heatsink on it.
Note: make sure that you are happy/satisfied with the sketch on the Atmega chip because once it's soldered on the board you won't be able to reprogram it.
Note: I also used a dremel to make a small hole on the bottom of the clock case so that the power adapter cord would neatly fit. I also used it for other various things while modifying the clock, like triming away sharp edges and just cleaning up the inside in general.
Step 7: Organizing Everything and Fitting It Inside the Clock
Once you have all wires and components properly soldered it's now time to organize the wiring and decide on proper placement of the board inside the Kit Cat housing. The main concern here is placing everything in a spot that won't interfere with the movement of the tail and eyes. I also didn't realize how difficult fitting in the speaker would be, so I had to drill some holes to help mount the speaker in a place thta would impede the tail motor armature.
Finding a place for the board can be tricky and may require some trial and error. I settled on a spot to the left, near the battery housing. I then used a hot glue gun on the edges of the board to help keep it in place. You may find draw ties or zip ties useful for organizing and grouping the wires neatly.
Whatever technique you decide to do this is up to you, because managing to fit everything inside the clock casing will depend on your clock and the amount of stuff going into it.
Finalist in the
We have a be nice policy.
Please be positive and constructive.