This DIY alarm clock is a project I made in 2018. This is actually the second time I build an Arduino based alarm clock. I made my first clock several years ago. Link to that project here: First Arduino Alarm clock
In this project, I have tried to use what I learned from the previous alarm clock and tried to make the best alarm clock possible. I have also used new techniques like 3D printing and PCB design.
Some of the main features of the alarm clock:
- Compact and easy-to-use design
- Always on, easy-to-read large LED 7-segment display
- An easy and fast user interface to set the alarm time (and clock time)
- RTC module with battery backup for keeping the time
- AUX power outputs for connecting and controlling 12v LED lights
- Visual and audible alarm signals using bright LEDs and dual buzzers
- Snooze function
- Easy to update the firmware and add new features
Electronics design
Click on the image to make it larger:
The Alarm clock is controlled by an Arduino Uno. I chose the Uno mostly because I have a few lying around, and it also has robust connectors for power and USB that I could easily integrate into the enclosure later. The Arduino Uno has too few GPIO pins for the functions I wanted to include in the alarm clock. Therefore I needed to do a few things to make it work.
Firstly I wanted 9 buttons for the user interface. The buttons are connected in a matrix together with some diodes. Three Arduino pins are used to drive the rows in the matrix and three pins are used to read the states of the columns. To read all the buttons, the first row is first activated, and the states of the first three buttons are checked, then the second row is activated, and the states of the next three buttons can be checked, and so on. This saved 3 GPIO pins since only 6 pins are needed to read 9 buttons.
Secondly, a 74HC595 shift register IC is used to drive all the LEDs. This allows all 8 LEDs in the Alarm clock to be controlled with only 3 GPIO pins. The clock has 3 indicator LEDs on top, the colon in the display counts as one LED, and there are four brick alarm indicator LEDs on the sides of the clock. The stated of all the LEDs are stored in RAM and the shiftOut() -function is used to control the shift register. This totally saves 5 GPIO pins compared to driving the LEDs directly with the Arduino pins the traditional way.
The Alarm clock also has a few other features. There are two power outputs for connecting external 12V LED lighting. Those outputs are connected to N-channel MOSFETs that are controlled by PWM pins of the Arduino, this makes it possible to adjust the brightness of the connected LED lights.
There are two buzzers in the alarm clock. One passive and one active. The passive buzzer is used together with the Arduino Tone() -function to generate almost all sounds the clock can make. It can generate sounds in a wide frequency range, it can also be used to generate click-sounds. This is used when holding down buttons to adjust the time for example. The active buzzer is really loud. It is only used to make loud alarm sounds if the alarm is not turned off right away.
The display is controlled by a MAX7219 7-segment display driver IC. It can be used to drive up the eight characters, but only four are used in my case. The IC controls the current to the LED segments as well as handling the multiplexing. There are also commands for turning on and off the display as well as adjusting the brightness.
I have included a light sensor based on an LDR connected as a voltage divider together with a resistor. The brightness of the LED display is adjusted between two levels depending on how bright it is in the room. This makes the display bright enough to see during the daytime, and not too blinding during nighttime.
The clock keeps track of the time using a DS3231 Real Time Clock module. Those modules are widely available from eBay and other places. It is an easy solution since it has a battery and keeps track of the time by itself. The Arduino communicates with it using I2C (Wire) interface.
PCB design
The printed circuit board (and also the schematic) was designed using the free EasyEDA web-based software. There are two boards. The main board and the display board. I designed the main board in a way that all the pushbuttons are on top and the Arduino is mounted underneath it. That way the entire package with my board and the Arduino can easily be mounted into to enclosure without the need for connecting wires to every single button. The four 7-segment displays and the display driver IC is mounted to the display board.
I have used a mix of surface mount and through-hole components. All SMD components have different footprints to make them easy to differentiate. There are two values of resistors used, I intentionally choose two different physical dimensions to make it easy to distinguish them from each other. There is a lot of space on the PCB, so there was not really any need for using SMD components at all, but I wanted to challenge myself and try it since I had mostly used troughhole before.
Assembling the PCBs
Assembling the board was pretty easy. Even the smallest SMD resistors were quite easy to solder using tweezers and a fine tip soldering iron.
I found that I have made a mistake on the display board. The board could be fixed by cutting a trace and then scraping off some of the protecting soldering mask and soldering adding a wire to the correct place. My repair could easily be seen in the image below. This mistake, as well as some silkscreen errors, are fixed in the download and EasyEDA link at the bottom of this page.
Designing and 3D printing an enclosure
The enclosure was designed in Autodesk Inventor. I made the enclosure after I have assembled the boards. This made it easy to measure dimensions on the real board using calipers, and inputting the dimensions into the CAD software. I wanted everything to fit together very precisely, Achieving this sill took two test prints and some modifications before I finally was satisfied with the third version.
The enclosure was designed in a way that everything screws in place and all electronics components mount from the inside out. This makes it easy to assemble and test electronics outside the enclosure and then install everything.
The result
The final clock works great. It works reliably and is easy to use. The four button interface makes it very easy and fast to the alarm time. Ther are two buttons to increment and decrement hours and two buttons to increment and decrement minutes. The buttons can be held down to make large adjustments or pressed to make fine adjustments. This interface makes it possible to set any time a just a couple of seconds.
Videos
Downloads
EasyEDA project with schematic and PCB layout: Link