DIY Sunrise Alarm Clock With Arduino

by nifty_knight in Circuits > Clocks

50 Views, 1 Favorites, 0 Comments

DIY Sunrise Alarm Clock With Arduino

Viewing user menus
Turning light on
Turning light off
PXL_20250817_003443895.jpg
PXL_20250810_005504817.jpg
PXL_20250817_004727013.jpg
PXL_20250810_005509560.jpg
PXL_20250817_003418520.jpg

Do you hate the sound of your alarm in the morning? Would you rather wake up peacefully, gently, and—most importantly—quietly? If so, consider designing and building your very own sunrise alarm clock! This article details the process of making a DIY sunrise alarm clock using an Arduino Uno. Note that while I soldered the electronics onto a piece of stripboard for a more permanent final product, you can just use a breadboard if you don't want to go through all the trouble. Similarly, I used the Onshape CAD program and 3D printer to design and create the case, but you can also make or just buy a case out of wood, plastic, or other material.

Supplies

1528_368_sml.jpg
IRF520-MOSFET-Breakout-Board.jpg
download.png
images.jpg
r60x0aa-xxx-1.jpg
download.png
PXL_20250429_171509818.jpg
PXL_20250806_001155587.MP.jpg
  1. Arduino - I used an Uno, but most other models should work similarly. You will also need a cable for uploading code onto the Arduino
  2. 12V LED Strip lights - 1-3 ft is more than enough. Getting a product with bare wires (no connector) is fine
  3. 12V DC Power Supply - This will plug directly into a wall outlet
  4. IRF520 N-Ch MOSFET Module - such as this one
  5. Ds1302 RTC (Real-Time Clock) Module
  6. LCD 16x2 Display - Such as the one shown here
  7. 2 2-pin Panel Mount Momentary Push Buttons - I used buttons similar to these; whatever buttons you use, the important thing is that they will fit into holes with a diameter of 11.8mm!
  8. Joystick Module - basic joystick, like the one shown here
  9. Breadboard and/or Soldering equipment & Protoboard - You can use a breadboard for testing and for the final product if you don't want to do soldering; using a protoboard will take more effort but result in a more secure product
  10. Jack-to-terminal block connector, something like this; connects power supply to Arduino & MOSFET
  11. 2.1mm Female barrel jack connector + attached wires for Arduino power jack
  12. 100 Ohm Resistors - I used 100 Ohm resistors because I already had them, I don't think the exact resistance matters too much for this project
  13. 3D Printer - To make the case

Wire Circuit

download.png
PXL_20250803_172633612.jpg
PXL_20250509_200548518.jpg
PXL_20250817_000727522.jpg
PXL_20250428_172903785.jpg
PXL_20250531_035718681.jpg
PXL_20250428_183507399.jpg
PXL_20250429_021714795.jpg
PXL_20250501_185836689.jpg

Circuit Step-Through


Power Supply - After doing some research, I found many noting that batteries used for hobby projects didn't last very long- I wanted this clock to be used regularly, so I designed it so that it drew power from the wall. The power supply converts the AC supplied by a wall outlet (typically 120V for North America, 230V for Europe, etc) into 12V DC that both the Arduino and LED strip lights can handle. Make sure the power supply you use is appropriate for your region. Note that the MOSFET and Arduino are wired in parallel, and the PWR and GND wires for each are both wired directly into the power supply's terminal block connector.

Connections:

  1. Power - Arduino Power Jack (ie. connect the power side of the terminal block to the Arduino's round power jack
  2. Power - MOSFET Vin
  3. Ground - Arduino Power Jack
  4. Ground - MOSFET GND

MOSFET - The MOSFET in this circuit is a voltage-controlled switch; when the Arduino sends a signal through the GATE line, the MOSFET connects the SOURCE and DRAIN pins, allowing electricity to flow through and light up the strip lights. The GATE pin of the MOSFET must be connected to a PWM pin on the Arduino in order to be able to modify the brightness of the light. Note that the Arduino pins cannot supply enough voltage to power the LED strip light, hence the need for the MOSFET. Note that the connections below apply specifically to the IRF520 N-CH MOSFET MODULE, and they can also be found on this website.

Connections (some are repeated):

  1. Vin - Power supply Power
  2. GND - Power supply Ground
  3. V+ - LED Strip lights Power
  4. V- - LED Strip lights Ground
  5. GND - Breadboard Ground strip
  6. SIG - Arduino Control Pin (pin 9)
  7. VCC is not connected

LED Strip Lights - The strip light is the source of light I chose for my alarm clock - in the end, I attached them to the wall above the bed with adhesive backing and had a wire going out from the case powering the lights. Make sure that they can be fully powered with 12V; some lights require 24V, which is too much for the Arduino to handle.

Connections:

  1. LED Strip lights Power - MOSFET V+
  2. LED Strip lights Ground - MOSFET V-

Real-Time Clock (RTC) Module - Keeps track of the time; I used a Ds1302 RTC Module

Connections:

  1. VCC - Breadboard Power strip
  2. GND - Breadboard Ground strip
  3. RST - Arduino Pin 5
  4. DAT - Arduino Pin 6
  5. CLK - Arduino Pin 7

Joystick - Used for user input, switching between menus and setting times

Connections:

  1. GND - Breadboard Ground strip
  2. 5V - Breadboard Power strip
  3. VRx - Arduino Pin A1
  4. VRy - Arduino Pin A0
  5. SW not connected

LCD - User screen. Typically, a potentiometer is used in conjunction with LCD V0 to adjust the contrast, but I didn't do this as I did not have one. If you would like to add one, follow wiring instructions on this page.

Connections:

  1. VSS - Breadboard Ground strip
  2. VDD - Breadboard Power strip
  3. V0 - Breadboard Ground strip (unless using a potentiometer)
  4. RS - Arduino Pin 13
  5. RW - Breadboard Ground strip
  6. E - Arduino Pin 11
  7. D0 not connected
  8. D1 not connected
  9. D2 not connected
  10. D3 not connected
  11. D4 - Arduino Pin 10
  12. D5 - Arduino Pin 8
  13. D6 - Arduino Pin 3
  14. D7 - Arduino Pin 2
  15. A - Arduino Pin A5
  16. K - Breadboard Ground strip

Breadboard - Useful for power and ground rails & making circuits with resistors

Connections:

  1. Use to connect resistors for Time & Select buttons
  2. Breadboard Power strip
  3. RTC VCC
  4. LCD VDD
  5. Arduino 5V
  6. Time button - 1 leg
  7. Select button - 1 leg
  8. Joystick 5V
  9. Breadboard Ground strip
  10. MOSFET GND
  11. RTC GND
  12. LCD VSS
  13. LCD V0 (Don't connect this here if using a potentiometer)
  14. RW
  15. K
  16. Arduino GND
  17. Resistor for Time button circuit (see note on notebook page)
  18. Resistor for Select button circuit (see note on notebook page)
  19. Joystick GND
  20. Other
  21. Arduino Pin A5 --- resistor --- LCD A (see note on notebook page)

Time & Select Buttons - Momentary push buttons - only change state while the buttons are actively pressed. These must each be connected with a resistor and an Arduino control pin in the breadboard - see the notes on the notebook page picture above for a connection diagram. This instructable also shows a diagram for how each button should be connected to the resistor and Arduino pin, just change the pin connection so that it matches the correct Arduino pin number for the Time and Select buttons. The code in the same instructable can also be useful for checking if you have wired the buttons correctly.

If you are using 2-pin buttons with holes in the legs, similar to these or those shown above, you can just bend the wires through the holes during testing - no need to solder until you are certain the buttons are working correctly.

Note: The buttons I used were inverted; they would disconnect the circuit (0) when pushed, and leave it connected (1) otherwise. If your buttons do not work this way, you will have to edit the pressed() function; use ctrl-f to find the pressed() function "FOR NON-INVERTED BUTTONS" and uncomment it, commenting out the pressed() function for inverted buttons.

Connections:

  1. For each button, see the instructable and diagram in notebook above
  2. Time button uses Arduino Pin A3
  3. Select button uses Arduino Pin A4

Arduino - The brains of the operation, controlling everything else.

Connections:

  1. Arduino Power Jack - Power supply Power and Ground
  2. 5V - Breadboard Power strip
  3. GND - Breadboard Ground strip
  4. Pin 2 - LCD D7
  5. Pin 3 - LCD D6
  6. Pin 5 - RTC RST
  7. Pin 6 - RTC DAT
  8. Pin 7 - RTC CLK
  9. Pin 8 - LCD 8
  10. Pin 9 - MOSFET SIG
  11. Pin 10 - D4
  12. Pin 11 - LCD E (enable)
  13. Pin 13 - LCD RS
  14. Pin A0 - Joystick VRy
  15. Pin A1 - Joystick VRx
  16. Pin A3 - Connects in breadboard circuit to Time button (displayButton)
  17. Pin A4 - Connects in breadboard circuit to Select button (selectButton)
  18. Pin A5 - LCD A

General

  1. You can generally change the pin numbers around, just make sure that the pin numbers on the Arduino match the pin numbers in the code
  2. Also note that some connections must be PWM, or analog, etc.
  3. For example, the MOSFET SIG pin must be a PWM pin, and joystick VRx and VRy pins must be connect to analog pins
  4. At this point, I would use a breadboard for the circuit, to make sure everything works before soldering. Soldering should be a final assembly step.

Add Code

PXL_20250727_205828541.jpg
PXL_20250501_190839673.jpg
PXL_20250531_035658372.jpg
PXL_20250803_155643813.jpg
PXL_20250803_224907258.jpg

Libraries

This code uses the Ds1302 library by Rafa Couto, which needs to be locally downloaded. This is easily downloaded through the Arduino IDE; search "Ds1302" in the Library Manager and download in the appropriate folder. Otherwise, the library (along with several versions of the code) can be found here. Similarly, the LiquidCrystal library may also need to be downloaded; this can be done through a similar process as the Ds1302 library.


Code Overview

The most updated version of the program so far is Full_program_v3.5, which is the one you will want to upload to the Arduino. In the above Github link, there are also several smaller programs which may be used and modified to isolate and test smaller portions of the circuit setup.

Once you have finished the circuit setup and uploaded the code to your Arduino, don't forget to test the setup at this point, especially if you plan on soldering later.


User Instructions

Pressing the select button will turn the display on, which shows a user menu. From the menu, you can:

Set Alarm Time - This will lead to a series of menus where you can select AM/PM, hour, and minute (in 15-minute increments) for the desired alarm time. Toggle the joystic up and down to change the values, and use the Select button to select desired values. Moving the joystick to the right will also select the current value, while moving the joystick to the left will go back to the previous menu or cancel the set alarm process if there are no more previous menus. Currently, only one alarm can be set at a time.

Set Current Time - This works similarly to setting the alarm time, but it affects the current time stored by the clock module. Caution! Currently, it can only be set in 15-minute increments (0, 15, 30, 45).

Move Time Forwards 1hr - This function is meant for daylight savings time; select this menu to move the current time forwards one hour.

Move Time Backwards 1 hr - This function is meant for daylight savings time; select this menu to move the current time backwards one hour.

Toggle Alarm - Selecting this menu option will not change the time set for the alarm, but will toggle its on/off state (ex. if the alarm was previously ON, it will be OFF after toggling, and vice versa). If the alarm is OFF, the light will not turn on even when the current time matches the set alarm time. This provides a quick and easy way to turn on/off the alarm for weekdays/weekends.

Time Button

The leftmost button is the Time button, press it to display the current time. The display will turn off automatically after 5 seconds.

Select Button

The rightmost button is the Select button, it is used for selecting menu options.

Joystick

The joystick is used for switching between menus. It can also be used for selection and cancellation (the 'back' function) when setting times.

Start/Reset

The current time must be set on program start, but afterwards it will retain the time even if the Arduino loses power, as long as there is a battery powering the RTC. However, currently any set alarm will have to be reset if the Arduino loses power or if the program is reset.

Design Case

PXL_20250713_223749966.jpg
PXL_20250713_210537627.jpg
Screenshot 2025-08-16 085910.png
Screenshot 2025-08-16 085841.png
Screenshot 2025-08-16 090216.png
PXL_20250713_210211336.jpg
PXL_20250727_202445282.jpg
PXL_20250530_182616155.jpg
Screenshot 2025-08-16 085752.png
PXL_20250601_021535396.jpg
Screenshot 2025-08-16 085826.png
Screenshot 2025-08-16 090038.png
Screenshot 2025-08-16 090519.png
Screenshot 2025-08-16 090546.png
Screenshot 2025-08-16 090458.png
Screenshot 2025-08-16 090349.png
Screenshot 2025-08-16 090338.png
Screenshot 2025-08-16 090327.png
PXL_20250806_034627228.jpg
PXL_20250806_034632113.jpg
PXL_20250806_050511118.jpg
Screenshot 2025-08-16 090100.png
Screenshot 2025-08-16 090152.png
PXL_20250808_021119270.jpg
PXL_20250727_202345864.jpg
Screenshot 2025-08-16 092152.png
Screenshot 2025-08-16 085800.png
PXL_20250712_171214117.jpg
PXL_20250604_161113070.MP.jpg
PXL_20250530_182516320.jpg
PXL_20250601_232820341.jpg

Design Process

The design process for the case was quite long, and turned out to be much more complicated than I initially thought it would be. Skip to the Print Files section of this step for less reading.

First, I created a rough prototype of what I intended the clock to look like- I wanted to get a sense of the size and design of the finished product. Next, I started by designing mounts for each of the modules (Arduino, RTC, MOSFET, etc). I initially started with a design that covered each side of the module, and printed out a mount for a test PCB. However, while researching alternative solutions, I came across a Medium article experimenting with snap-fit plugs, and consequently decided to try and create my own in Onshape, based off of William Andrews' design. I tested several different sizes before settling on a final size and creating a prototype mount for the joystick module. I also had to make multiple different versions for the joystick mount; my first version included a cover for the pins, but that plan was scrapped after I realized that it blocked the joystick from properly sitting on the mount. Similarly, I had to make a few different versions to get the sizing just right and the snap-fit plugs in the right places.

After that, I designed plugs and mounts for the other modules, using the joystick plugs to get rough dimensions and then taking into account each module's unique PCB height and hole size for the final fit of the snap-fit plugs. Simultaneously, I tested the placement of each module relative to the others, seeing if they would all fit together, as well as testing the size and placement of holes in the box for powering the Arduino and MOSFET, for the Arduino code upload port, and for the LED lights to connect to the MOSFET.

After figuring out the requisite measurements for the plugs, mounts, and minimum size of the clock box, I started experimenting with lid design. I tried a few versions of a spring-loaded lid (which I imagined would make a satisfying click sound on closing), but ultimately decided upon a much simpler brim design which was simple and clean-looking. Speaking of clean-looking, I finally realized that my first prototype much more resembled a shoebox than a clock, so I played around with multiple designs and aesthetics on Onshape until I found one I liked. Comparing the original box to the final version, I'm very happy with the choice I made. However, with the new lid design, I was having problems; because the lid was hollow on the inside, but the snap-fit plugs stuck out of the top, each print required a lot of support. I wasn't sure how to resolve this problem until a family member suggested that I create recesses for the plugs, so that the top of each sat flush with the surface of the lid. After a bit of trial and error, I was able to create a final lid design that was much better, reducing material used by 15% and decreasing print time by 40 minutes!

Finally, I began soldering the final circuit, but was having a lot of trouble soldering solid wire to bridge the pads of a piece of protoboard that I bought. I decided to use stripboard instead, but consequently had to create a new mount for the piece. I broke the stripboard into a smaller piece to fit into the box, and designed the mount to use the original side-covering design, since the broken pieces didn't have holes on all sides for the snap-fit plugs. Lastly, I redesigned the base of the alarm clock case with the new mount, and printed out the final version of the base.

Print Files

  1. Original Version - Print "Box - Original" and "Lid - Original" for the original sizing; however, the sizing tolerances with this model are quite tight and may make it difficult to assemble
  2. If you do not have a specific sizing of stripboard which fits well into the mount (around 27x95mm, no bigger) then use the large version
  3. Large Version - Otherwise, print "Box - Large" and "Lid - Large"; this version is wider for easier assembly and has a larger 55x100mm recess and no mounts for the stripboard - this allows for different sizings of stripboard which may not fit well into the mount
  4. If you want to reduce soldering, a small breadboard should fit comfortably into this version

Final Assembly

FWAF7HDMEBUTF67.jpg
PXL_20250803_165635395.jpg
PXL_20250806_001201031.jpg
PXL_20250803_165748154.jpg
PXL_20250806_044238982.MP.jpg
PXL_20250806_001252554.MP.jpg
PXL_20250810_005515460.jpg
PXL_20250810_005419511.jpg
PXL_20250810_005509560.jpg

Soldering

At this point, once the electronics are working, you may want to solder them to create a more permanent circuit and reuse your breadboard for a different project. My setup was quite simple; I made use of a few thick books and blu-tack to help me hold the board and wires in place while soldering. You can follow the diagram in the notebook above to solder wires into the right places; Note that you will want to use stripboard like the brown piece pictured above, which has copper traces connecting several holes for the power and ground rails, and for the circuits containing resistors, which allows for mimicking breadboard connections. I did first attempt to solder my own connections using solid wire onto a protoboard with no connections between holes, but I was unsuccessful, and I had to desolder everything and resolder onto the new board. Don't do that unless you have great soldering equipment and maybe also some flux.

Be careful when soldering wires to the buttons, as the wires need to go through the lid!

Assembly & Mounting

Assembly should be fairly straightforward; just be conscious of the order in which you attach wires and modules to make it easier. Finally, add a standard cell battery to the RTC module; that way, it can keep track of the time even if the Arduino is powered off.


And that's it! We're done. Enjoy your now-peaceful and relaxed mornings :)