The Sunrise Alarm Clock

Introduction: The Sunrise Alarm Clock

Ever woken up in the morning, looked at your alarm clock, and wished you'd woken up about 5 hours earlier? I know I have. As one of the dreamiest sleepers in the world, I have not found a single alarm clock (or a combination of them) that has ever been loud enough to wake me up permanently. Thus, this project. This project started with an article I read about how "dawn-simulating" clocks are far more effective at waking people up than just regular alarm clocks. So I thought, why not build one? And then I got started.

This project has been my single greatest learning experience since I started working with microcontrollers two years back. From the code to soldering to getting the right voltages for different components (3 different voltages specifically), this definitely was a difficult project. But I think the end result is an alarm clock that actually lives up to the name. The lights turn on twenty minutes before the actual alarm. While some people say that you need the light to slowly gradate in intensity, I found that low intensity LEDs were practically as good as turned off. Therefore, I took a decision to turn them on completely twenty minutes before the actual alarm itself.

Update: I got some feedback that the look of the front was quite bad initially because the paint brought out the defects in the wood. The reason I wasn't able to sand the wood down properly is that it was all manual. However, I do realize that it should look better than that and so I experimented with some materials. When I put a piece of cardstock printed black on the unit, covering all the sides with it, I thought that it looked better. I was completely sold on the cardstock only after I turned on the LED strip, which, I think, looks nice through the cardstock. I don't need the LED strip to wake me up as I can plug any nightlamp into the unit to do the same thing.

Lets get started!

For more pictures and projects, please visit my blog at

Step 1: Materials and Tools Required

Materials (Total Cost: $80 - you will probably have a lot of the smaller components already, this cost is an absolute maximum)

  1. GLCD Negative backlight - $18.95
  2. Speakers - $3.22
  3. Female AC Plug - At your local hardware store - < $1
  4. Soldering Circuit Board - $1.5
  5. Atmega328 - $2
  6. 16mhZ crystal - <$1
  7. 18pf capacitors, 0.1uF caps (2 each)- $1.50
  8. Multistranded Wire - At your local hardware store - < $3
  9. DS3132 + Coin Cell - $1.50
  10. 5V AC Relay (optoisolated) - $6
  11. Power Supply - 5V - $3
  12. Zener Diode - 3.3V - <$1
  13. Assorted Resistors - $10 (you can get them for much less as well)
  14. Female Headers and IC Sockets (1, 2) -- A maximum of $5
  15. Potentiometers, knobs and buttons - $7
  16. Plywood (anything above 1/2" is fine, but the plans attached make use of 0.6" plywood) and assorted screws- maximum of 15$ (you can even use scrap wood)

Optional ($15)

  1. LED Strip - $5-6
  2. Mosfet - <1$
  3. Power Supply 5 & 12 V - $8


  1. Soldering Iron and Solder
  2. Arduino Leonardo (for other arduinos, uploading the code might be slightly different)
  3. Laptop
  4. Jigsaw
  5. Drill

Step 2: Preparing the Circuit Board and the Soldering

The schematic is attached in 3 parts. I strongly recommend using headers on all the pins and IC sockets for all the pins. It saves a lot of damage from happening to the pins which only prolongs the project.

  • The first one are the GLCD pins along with the ST7565. This also has the wiring instructions for the crystal on the arduino.
  • The second one is the DS3231, button, potentiometer and the speakers
  • Optional: The 3rd is the schematic for the LED strip
  • For the optoisolated relay (you should connect this especially through header, it makes it easier to connect), use the pinout (which is different for each relay) to solder connections from pin 19 (digitalpin13) of the arduino to the relay switch.

Tips for Soldering

  1. If you absolutely new to soldering, I suggest using headers in all parts of the projects, preventing any damage of electronics.
  2. Refer to image 4,5,6 to see how to get a mechanically strong soldering joint that is also easy to solder. The idea is to cut an about 1/2" part of the wire, then starting from 2 holes behind the point you want to solder, thread the wire through from under the plat to the top of the board. Then thread it back down through the next hole. This creates an incredibly strong joint which can be soldered.

Step 3: Preparing the DS3231 and the ATMega328P

First, the ATMega328P. If you are using a Leonardo, I strongly suggest you go through this excellent instructable on how to uploard to an ATMega using the Leonardo as an ISP (it is a bit more work than using the UNO). If you are using a UNO (or earlier models), follow this procedure

  1. Using the above circuit mappings, connect the following pins togethor from the UNO ICSP header and the ATMega328P:- MISO, MOSI, SCK, VCC, GND
  2. Then connect the of the ATMega to ground with a 10k resistor and also to pin 10 of the UNO
  3. Plug the Arduino into the computer and open up the IDE. Go to File -->Examples --> Arduino ISP
  4. Go to "# define RESET SS" and change it to "#define RESET 10"
  5. Upload the code to the UNO
  6. Connect the XTAL pins of the ATMega with a 16MHz crystal. Then connect the pins of the crystal to ground with capacitors (this is not optional, the caps are critical to the functioning of the oscillator)
  7. Go under Tools-->Programmer-->Arduino as ISP
  8. Go under Board --> Nano (ATMega328)
  9. Now uncomment line 22 in the code attached and upload it to the ATMega. Then power down the Arduino.
  10. Now attach the power and ground pins to the DS3231. Using the ATMega pinout above, connect the SCL and SDA pins of the UNO to the DS3231 SCL and SDA (they will be labelled on the chip).
  11. Power on the UNO (still connected to the ATMega), and this should assign the right time to the DS3231.
  12. As an alternate to steps 9 & 10, you can upload the code to the UNO, and then use its SDA and SCL pins to reprogram the DS3231.
  13. Next, re-comment line 22, and upload the code to the ATMega.

That's it, your ATMega and DS3231 Clock Module are ready!

Step 4: The Code and And What It Does

  • The initial code uploaded with line 22 uncommented sets the RTC to the time the code was uploaded to the Arduino. If you leave this line in the code, then the time will reset everytime you turn the Arduino on, which is clearly not good.
  • The button is activated by an interrupt which allows the code to check for the buttonPushCounter value to constantly update and not go through the entire code everytime
  • The loop function checks the buttonPushCounter value and updates the LCD based on the current push counter
  • The next function, buttonPush, is the interrupt function. This is called everytime the Arduino detects a rising edge on the buttonPin.
  • The function bigNumber has two arguments, 'select' and 'offset'. 'Select' chooses which of the large numbers is to be called. Since the y-coordinate of all the numbers remains the same, only an x-offset is required. This is what the offset function does. All the numbers within the function are drawn using the "drawline" command.
  • The displayTime function makes use of the bigNumber and the RTC values to show the time with the proper offsets. The reason I made this a separate function, is that the "loop()" function requires it multiple times. This saves space and makes the code more efficient.
  • Coming to the last, and what I suspect will be controversial, part of the code the playMusicandLight function. The reason that I haven't used an array to encode the music, is because the code never works with it for some strange reason. While the tone code works independently on the Arduino, it doesn't work within this program. Therefore, I was forced to generate all the raw code for the tone. If you're interested, there are some really cool tones here. If you want to know how I generated the code, look at my blog here.

That's it the code is done!

Step 5: Testing the Circuit (Important)

While your soldering might be impeccable and all the connections might have been tested on a multimeter, this is an incredibly important step. Testing your circuit before the project is started is a very important step. And, quite frankly, its the most fun. Seeing the electronics work togethor is a truly magical moment, atleast it was for me. Once, this is done, if it works, you can seal off the wires with some hot glue to prevent shorts. If the circuit doesn't work, recheck all the connections with a multimeter. Use a UNO/ Leonardo to test each component separately. If it still doesn't work, use the Arduino Forum, its a great resource. If your electronics still doesn't work, try removing the relay and testing the circuit. If it works then, check the next step to see how you can fix the problem with the relay. Good Luck!

Step 6: Finishing the Electronics

The AC Connections

Using the images above, connect one pin of both the female plugs to one of the AC outlets (we don't have ground and neutral pins in India, so this is directed towards those using European type sockets, although I imagine that it wouldn't make a difference whether ground or neutral was connected to any of the plugs). Then connect the other AC outlet to the central tap of the relay. Connect the "Normally Open (NO)" part of one relay to one female plug and close it off. Connect the "Normally Closed (NC)" to the other AC Plug. If you are confident of the strength of the connections, use hot glue to seal everything off.

Attaching the Relay

Now, the part where everything can go wrong, the relay.

"Relays are high reactance loads where the current builds slowly when switched on and decays slowly when switched off. The problem with a relay at switch off is that as the current collapses a voltage spike occurs which can damage semiconductors so a reverse diode is placed across the coil to short out this spike." Courtesy: kcraske

Now, there are a few solutions to this problem. The first is to use optoisolated relays, which this project does. What these do, is create a gap between Arduino control circuitry by using a light to activate the relay rather than electronics. However, the relay might still create problems. The next fix is to attach a 47uF electrolytic capacitor in between the positive and negative ends of all the power supplies (5V, 3.3V and 12V if you are using the LED strip) with the right polarity. There are a few more solutions too which you can find here.

Finishing the Button

If you don't have a long pin pushbutton, the top of the pushbutton probably won't fit through the wood. To make a top for it, cut a part of a pencil and paint it as in the pictures (or any colour you want). Then use superglue to attach it to the top of the pushbutton.

Step 7: Optional Electronics Add-Ons

LED Strip

This is a nice little add-on if you don't want to keep adding plug-in bulbs to the project. However, it does require the handling of an extra voltage. I added it to mine and I think that it is worth the extra effort. Besides, it allows you to sidestep the relay entirely and save yourself from those high impedance monsters!

Colour Adjust on the GLCD

This is incredibly simple and a very nifty add on. Just connect the three colour pins (R,G,B) to the centre taps of 3 different 10K potentiometers. Then connect any one end of each of these pots to ground with a 220 ohm resistor in between. Thats it! You can now get any colour in the spectrum (well, almost any colour). It really adds a lot of bright LEDing to your project! For a demo of this, check out the intro video.

Step 8: The Case - 3D Printed Version

Now that the electronics are finished and working. Now there are a couple of options you have. First is the template above which you can stick to wood and cut out using a jigsaw. The second option is using the ".stl" files or the "Autodesk123D" that I have attached here. However, I haven't printed this out personally and do not know how well the print will hold up. The files are editable, so you can make any changes you feel like!

Step 9: The Case - Wooden Version

Now, the instructions for the wooden case.

  1. Cut the pieces according to the template.
  2. Attach the front and the two flat pieces (the ones without the female AC plugs) using glue.
  3. Attach the AC-DC convertor to the bottom of this case using screws and a drill.
  4. Next finish off the front piece by hot gluing the speakers on to the holes, hot gluing the buttons and potentiometer to the holes on the case, and screwing in the GLCD to the allotted space.
  5. Next, the sides. Make the holes for the plugs so that it just fits. Then, put the AC plugs in on both the dies and hot glue them in place. Remember, there is never too much hot glue!
  6. Finally, the back. Attach felt pads to the bottom of the circuit board to prevent bending and short circuits. Just screw the circuit board in place making sure you keep the DS3231 facing upward, otherwise, it might hit the AC-DC converter.
  7. Finally, use pilot holes, countersink them and then use screws to attach the screws and back to the main piece. Use the pictures above as a guide.
  8. Now its time to sand and paint all the pieces. Make sure you make the project look good, otherwise you would have spent all this time for nothing!

Step 10: The Case - Optional Add-ons

Optional: If you have the GLCD colour adjusting potentiometers, attach them to one of the sides as shown in the picture. If you have the led strip, make a hole to put it through and stick it to the sides with either double sided tape or hot glue.Make a hole for the power cord to come out of and attach that to a plug. Once that's finished, the project is done! You finally have a good way to wake up!

Thanks a lot, and please visit my blog!

Step 11: The Makeover

While the alarm clock did work well, I had received some criticism that said that the project did not look very nice. A few people rightly said that the way I had painted my wood had made all the imperfections stand out in it. While experimenting with different finishes, I came across a sheet of card stock. I used this to finish my project by printing a large sheet of card stock black, and then using it as a laminate to cover all sides of my project. Unexpectedly, the LEDs turned out looking quite nice inside the card stock, and I think the entire project has an improved look. Let me know what you think!

Make it Glow!

Participated in the
Make it Glow!

Homemade Gifts Contest

Participated in the
Homemade Gifts Contest

Be the First to Share


    • Science Fair Challenge

      Science Fair Challenge
    • Stick It Challenge

      Stick It Challenge
    • Home and Garden Contest

      Home and Garden Contest



    7 years ago

    Good project but may I suggest you look up about relays. You say that they are high impedance loads and so draw a lot of current at switch on and off. In fact they are high reactance loads so show current builds slowly at switch on and when switched off decays slowly. The problem with a relay at switch off is that as the current collapses a voltage spike occurs which can damage semiconductors so a reverse diode is placed across the coil to short out this spike.


    Reply 7 years ago on Introduction

    I've changed it and quoted you. I hope that's alright :) Thanks for that correction, I'll be sure to be more careful next time


    Reply 7 years ago on Introduction

    Oh, thanks for that. I'll make sure I edit that bit of my project :)


    7 years ago

    Perhaps I was not quite clear in my comments, they refer to using a relay not an opto isolator.


    7 years ago on Introduction

    Great work! I've wanted one of these sunrise alarms for years, but never had the thought to make one. Nicely done!


    Reply 7 years ago on Introduction

    Thanks a lot! I was looking around for an intstructable to try and replicate, but then I didn't find anything which used Adafruits' GLCD. I really like that LCD and so I decided to make an alarm clock myself using it. Thanks for the comment! :D