How to build a wooden digital clock powered by an atmega168 (arduino) with a built-in alarm and games.
I first thought about making this when I saw an LED clock covered by a wood veneer . I liked it when I saw it, until I saw the price. This is when I decided to build my own, I wanted it to build it for much less, from solid wood and play games!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What You Need
- 4, 18" x 4" x 1" wood planks (I went with Maple)
- 85 Red LEDs
- 85 Green LEDs (Optional)
- 1 4 to 16 pin Demiltiplexer
- 15 NPN transistors (such a 2N3904)
- 1 ATMEGA168 Microcontroller (or Arduino)
- 1 20 MHz Crystal
- 1 5 Volt Regulator
- 2 220uF Capacitors (for power spike leveling)
- 1 Old Pocket Radio
- 2 1/8" Audio Jacks
- 1 5-9V DC wall adapter
- 1 (or more) Old Game Controller(s)
- 4 3-1/2" Wood Screws
- Solid Core Wire (easier to work with)
- Hot Glue Sticks
- White Glue
- Sand paper
For the game controller I use an Atari 2600 joystick (or even paddle if you re-program), but it is also compatible with with a Sega Master System Controllers, Atari 7800 joysticks (theoretically) or even Sega Genesis Controllers.
- Drill press
- Flat End Hobby Tool Bit
- Soldering Iron
- Hot Glue Gun
- Miter Saw
Step 2: Prepare the Front Board
Take the best piece of the 1"x4"x1-1/2' board and choose the best side to be the front of the clock.
Try to avoid any knots or visible defects in the wood because they will make it infinitely harder to drill the LED holes.
Start by printing out the template attached to this step at a 1:1 scale.
Tape it to the back side of the front board, so the good side is facing down when the print-out is facing up.
Take the front board and place it template side up on top of the worst looking board. Then put that on the drill press.
Take a drill bit slightly larger than the flat-ended hobby bit and adjust the depth gauge so that the tip is just 0.8-1mm above the lower board, this is so it doesn't go all of the way through the front board. I strongly suggest using a test board first to see if it works. Drill at least 10 test holes (they will be used later!). A strong light should be able to shine through where the tip of the drill ended.
Drill one hole in each of the circles on the template as in the picture below.
Step 3: Finish the Front Board
This step is very challenging, the point of it is to use the hobby tool bit to make the hole ends flat so the light shines through evenly.
Start by putting the hobby tool bit in the drill press (make sure to leave over 1" out of the chuck).
On a safety note, this is not how the bit is designed to be used, and is a hazard, so be extra careful. Adjust the depth gauge so the bit is barely above the lower board as in the 3rd picture.
Line the bit up with a test hole and gently hold down for 1 second and let up. Hold it down for 1 second again then let up and turn the drill off. The drill is turned off so you can scrape any build-up off of the bottom of the bit. If you don't, it will burn the hole making the face discoloured. Repeat this until you are happy with how much light shines through (see pictures below for a reference).
Once you are comfortable with drilling the holes, move on to the final piece of wood and drill out each hole. Be warned that this takes patience, don't rush it or you may burn out a hole and have to restart.
Step 4: Prepare the Middle Boards
This step prepares the middle boards to accommodate the electronics.
If you messed up in the last step, the wood isn't lost, use it here!
For this step, all you need to do is cut a hole in each of the middle boards slightly larger than the size of the LED matrix, so all of the wires and electronics fit inside.
I did this by drilling out the remaining supports of a failed front board and using a chisel to clean it up. Repeat this for as many boards as you wish, I used 2.
Step 5: Prepare the Back Board
For this step use the attached template to drill and carve out the holes for the DB9 connector used for the controller, and the 2 1/8" audio jacks used for power and the radio.
To carve the controller port, drill out the inner line on the template. Next, carve the outer part of the template 10 mm deep using a chisel (be careful for this step, it's sharp).
To drill out the holes for the 1/8" jacks, start by drilling a hole just large enough for the end of the audio jack to fit into. Next drill a larger hole from the inside of the board to within 3mm of the outer surface(this depends on your jack). This allows the end of the jack to sit snugly in the smaller hole with the rest hidden behind the wood.
At this point you will want to attach the wires to the power, audio and controller ports. On the controller port, connect the wire from pin 5 to the wire from pin 6 as seen in the last picture.
Finally, fasten all of the ports to the back board using hot glue on the inside.
Step 6: Solder the Matrix
For this step, place one of each type of the LEDs in each hole so they wedge in place. If you used 2 5mm LEDs like me, then you will need to widen the the holes for the LEDs. Be careful when doing this, the drill bit can catch much easier and pull the board up, poking out the hole.
If you used 2 LEDs, then when you insert the LEDs into the holes, place the cathodes in the middle of the hole, so the 2 flat sides meet.
To start soldering, first bend all of the cathodes (shorter leads) down so they form 17 columns very close to the board, then solder them together.
To solder the anodes together first bend all of one colour's anode up and then bend them horizontally, so there are 5 anode rows for that colour. Bend the other anode colour's leads down and then horizontal, so they form another 5 anode rows.
Now solder all of the rows together so there are a total of 10.
The final part of this step is to solder wires to the rows and columns for the electronics to hook up to. When choosing the length of wire, run the wire from the row/column to where you want the electronics to be placed and add 5-10cm extra to work with.
Step 7: Start Assembling the Boards
For this step you will need one middle board, the front board and 2 'sacrificial' pieces of wood (they will be noticeably dented).
To start, take the white glue and apply it to the front side of the middle board, don't be afraid to apply too much, it its better than too little.
Using a finger, wipe the glue evenly across the whole side and stick it on the back side of the front board (see the pictures for more clarification).
To make a strong bond, place one piece of 'sacrificial' wood on either side of the now glued pieces and clamp it together (be sure to align it quickly, because it dries fast). To make the best seal, clamp it with everything you have (see second picture below), but be careful not to break the wood or poke out the LED holes.
Step 8: Program the Microcontroller
This step may sound simple, but it can be vary confusing is not done properly.
I loaded the program onto the atmega168 by using an avrisp mk II to circumvent the bootloader on most chips used with Arduino. This is because I wanted an instant startup, and it also allows for more program space(although, not much).
To do this, there are good resources here, here and here to burn a bootloader. In place of the bootloader just use the .hex file found in the applet folder of the arduino sketch folder (which is the one I have attached to this step and the introduction).
To change any aspects of the file, I have also included all of the commented code, just click 'upload to board' (you will get an error unless you have an arduino plugged in) to re-compile and the .hex file will change to the new code.
Odds are that your crystal won't be exactly 20.0Mhz, so it will need to be calibrated to keep accurate time. To do this, just change the oneMin variable in the code, mine is 60116.
The clock speed is currently compiled to run at 20 MHz. To change it you will need to change some numbers in the arduino preferences and board definition files, as found here.
Step 9: Build the Electronics
To build the electronics, follow the attached schematic. I have attached the schematic as a bmp, two different sizes of PDF, and the original .ms10 file created in national instruments' multisim software, for those who so desire to use it.
The cathodes of the LEDs hook up to the outputs of the multiplexer, with the left column of LEDs being column 0. The demultiplexer needs to sink the LEDs one at a time, such as the one in the attached data sheet.
The anodes of the LEDs are attached to a cluster of 3 transistors. This is so the 1st transistor has the power directly from the adapter attached to its collector pin, the corresponding anode pin(from the microcontroller) is attached to the gate. It also has the emitter going directly to the gate of the 2nd transistor, and using a 1kOhm resistor it is connected to the gate of the 3rd transistor. The 2nd transistor has its collector attached to the green pin (pin 1 on the arduino) and its emitter attached to the green(or your highest draw LED) row. The 3rd transistor then has its collector attached to the red pin (pin 0 on arduino) and its emitter attached to the corresponding LED row. It should be noted that I ordered the LED rows from 0 at the top to 4 at the bottom.
The radio power is attached to the speaker pin (pin 9 on arduino), so that when the alarm is sounded it turns on and automagically tunes the strongest station.
The controller pins (analog pins 0-5) all have a 200kOhm pull-up resistor. the pins from 0-5 (followed by the corresponding DB9 number) attach to the controller in the following order: up(1), down(2), left(3), right(4), button1(5 and 6), button2(9, also optional). pin 7 on the DB9 connector is +5V and pin 8 is ground.
See the pictures for some comments and pointers, but if something is unclear let me know in the comments and I will do my best to help.
For the ports and LED rows and columns, I suggest installing sockets so the parts can be easily removed or swapped.
Now attach the wire to the LEDs, power and controller and test. Before you insert any chips make sure the power they are receiving is the correct 5V, so they aren't destroyed.
Step 10: Finish the Clock
For this step, clamp all of the boards together, then using the template attached to this step, drill pilot holes for the 4 wood screws (only up to the start of the front board, which is why the one behind is glued). If you want you can counter-sink the holes so the screws sit flush.
Now insert the screws into the holes.
The last thing to do is clean up the edges. Take the miter saw and cut the ends an equal distance from the screws on either side as in the template (be very careful at this point as not to poke out a hole on the saw!).
Now just sand any uneven or rough edges (not the front) and you are done!.
Step 11: How to Use the Clock
To set the time, push and hold the button for 3 seconds, the screen should go black. To change the flashing number, push up and down. To switch between numbers push left and right. While switching between numbers, you will come to the colon, when on the colon switch between AM and PM by pushing up and down, the colour will change between red and green (AM and PM are whatever you want them to be). Push the button again to set the time.
To switch between the various other functions push button 1. It is also possible to push button 2 (not in atari 2600 controllers) to turn the radio on and off. To return to the clock, push and hold button 1 any time.
The order of the functions of the software are as follows:
Alarm - set the same way as the clock.
1-D Pong - It's all about timing, Played by pushing up/down to choose the number of players and bushing button 1 to confirm. To play push button1(for player 1) or button 2 (for player 2) when the ball is coming at you, but not too early or late or else you will miss.
Labyrinth - Find your way out, It is a maze, but all of the keys need to be collected to open the exit.
"Jump" - A platform game, avoid the red dots and don't fall to get as far as possible.
If you have any questions don't hesitate to leave a comment! Let me know what you think.
Participated in the
The Instructables Book Contest