Digital Alarm Clock

Digital Alarm Clock Banner
I’ve decided to make a Digital Alarm Clock for my diploma final year project. Before I start this post, here’s a video about it 🙂


The Hardware

  • Atmel ATmega328P Microcontroller with 32kB Program Memory and running at 16MHz
  • Philips PCF8574A IO Port Expander
  • Maxim DS1307 Real-Time Clock
  • 16×2 HD44780 Monochrome LCD with Blue Backlight
  • UM66 Melody IC
  • 4×3 Numerical Keypad
  • LM7805 Voltage Regulator



  • Display Time in 12-Hour AM/PM Format
  • Display Date in dd/mm/yyyy Format
  • Display Day
  • Set Alarm Time
  • Set Date
  • Set Time
  • Menu Based Navigation System
  • Anti-Sleepiness Alarm Function
  • Auto Generated Day Function


The Making of the Digital Alarm Clock

This Digital Alarm Clock project started its’ life on a breadboard, and with a brand new ATmega328P MCU bought from Cytron.

Together with the Microcontroller, I bought the UC00B USB to Serial adapter to program the MCU using the Arduino IDE.

To make it work on the Arduino platform, the microcontroller must have the appropriate bootloader. There are many ways to burn the bootloader but I settled on the ArduinoISP method (using my Arduino Uno R3).

I made a video on the bootloader burning process.

After successfully burning the bootloader, I can now use the Cytron UC00B USB to Serial adapter to upload code into the MCU.

With the basic Arduino circuit done, I can start the programming and also assembling other hardware components.

To read more on how to make your own Arduino on a breadboard, read this post 🙂

Next, I made some special push buttons so that the user can identify its’ function more easily.

Here’s how I assembled these push buttons.

I ended up using 4 breadboards to completely construct the prototype circuit.


Writing the Code

First and foremost, I should mention and give credit to a few libraries that I’ve had to use in my code.

  • Wire by Arduino (Source) : Establish I2C connection to/from the PCF8574A and DS1307
  • LiquidCrystal by Arduino (Source) : Interface with the HD44780 LCD
  • I2CKeypad by Angel Sancho (Source) : Interface with the 4×3 Keypad through the PCF8574A
  • TrueRandom by Peter Knight (Source) : Generate true random numbers for the random math question

Other than the libraries mention above, the code is solely written by yours truly.

It is 1,029 lines long, and takes up around 16kB of program memory. It took me close to 50 hours to come up with this.

My initial idea of using an ATmega16 to cut cost was scrapped because this code and the bootloader takes up around 18kB of  program memory, which is more than the 16kB capacity of the ATmega16.


Designing the Schematic and PCB in Eagle 6.2.0

I chose to use the Eagle software to design the schematic and PCB because the library is huge and it’s simple to use (IMHO).

This is the final revision of the schematic :

Initially, I plan to make a dual layer PCB but because of time constraint, I had to settle for a single layer PCB.

This is the final revision of my PCB.

I’ll admit that I used autoroute, and it’s not that smart, so I had to give it a bigger workspace to work on. Thus I’m using a 25cm by 15cm PCB.

Printed the PCB layout on a transparency sheet to mask the PCB from UV exposure.

I’ve wrote a post before this on how to make your own PCB. You can read them here 🙂

The end result.


Tour of the Board

At the centre of the board is where all the magic happens, ATmega328P MCU, DS1307 Real-Time Clock and the PCF8574A IO Port Expander.

There is also a backup battery for the DS1307 Real-Time Clock IC. Even if the power runs out, the ‘clock’ will still continue to tick.

The 6 Buttons. Menu, Back, Forward, Cancel, OK and Alarm ON/OFF.

At the bottom left is the 4×3 Numerical Keypad for user input. It is used for setting the time, date and also answering the math question.

At the top left are the buzzer, the UM66 Melody IC, and a 10k potentiometer to adjust the LCD Contrast.

Lastly, at the left hand side of the board is the programmer port, where I can plug in the UC00B USB to Serial adapter to upload a new code into the ATmega328P.



Menu-Based Navigation System

The user can press the Back and Forward button to scroll through the Menu. To select the desired function, press Enter.

Anti-Sleepiness Alarm Function

To turn off the Alarm, the user has to answer a simple math question. The alarm will not turn off until a correct answer has been entered. The question is generated randomly everytime the alarm rings.

Auto Generated Day Function

To set the date, the user doesn’t have to enter the Day. The code has an algorithm that will determine the correct Day that corresponds to the date entered.


Project Costing

Below is a list of all the components that are used in this project and also their cost. So much money!

The total cost shown below does not even reflect the true amount of money I spent, there are things like troubleshooting cost, buying new components to try out, soldering cost, flux, damaged components, etc.


Looking aside the cost, I’m thankful that I’m able to complete this project and I did learn alot from it.

I hope you’ve enjoyed reading this post as much as I’ve did during the making of this project.

Thank you 🙂

Print Friendly
  1. x10-12-2019

    Parce que du style de Pacquiao, il va essayer de submerger Mayweather.

  2. b10-09-2019

    It cohérente fait aussi pas mal que le buteur de Bale a été solide tout au long de l’année et qu’il joue également un r?le énorme dans la conduite du Pays de Galles grace à la qualification pour la Coupe 2016 Euro en France.

  3. COSKUN MMUTI08-23-2018

    Hi, very nice project. Can you share me schematic? Thanks ([email protected])

  4. KALYANKUMAR S04-12-2016

    please sent this project report

  5. dejan02-28-2016

    Who want a code for Arduino alarm clock with DS3231 and LCD 16×2 I2C:

    • dejan02-28-2016

      BTW, this is a great project 🙂

  6. Rajat sharma02-04-2016

    Hey, great work
    Awesome project
    Can you please send me the code for the alarm clock ….
    Need it urgent ……
    Appreciate it…..
    Email: [email protected]

  7. Rajat sharma02-04-2016

    Hey, great work
    Awesome project
    Can you please send me the for the alarm clock ….
    Need it urgent ……
    Appreciate it…..

    Email: [email protected]

  8. bappi12-29-2015

    please can u send me the code for this project as i need it very much…….thank you…….my email id: [email protected]

  9. Stefan Mihnea11-17-2015

    Please send me the code because I need it . I am student robotics club and I want to do this project for a very important project competition . This is my email address : [email protected] . Please send it to me because I want to add one more medal to my collection . I already have four medals, Please !!!!!!

  10. Stefan Mihnea11-17-2015

    hi, can you send me all cod?
    [email protected]

  11. QAMAR SHAIKH03-28-2015


  12. Albert12-13-2014

    Hi, With big interest I have taken a look at your digital alarm clock. there are some parts I would realy want to know how you created it. The menu is having my interest and the way you play the alarm sound. It is now 2 years after your exam can you share the code with me? or at least the parts that play the sound and the menu you have created. I’m trying to build a clock with a rotary encoder and only one button but I’m stuck in creating the routine’s to set the clocks date/time

  13. alisonwebAlison08-21-2014

    please send me code!

  14. RAJESH.G07-11-2014

    Sir please send me the code .I am waiting eagerly (atleast send me the steps to write a program ) pleaseeeeeeeeeeeeeeeeeeeeeeeeee.

  15. ika03-25-2014

    can i know where i can get um66? and how can i found component um66 in multisim? if you can help me

  16. John01-23-2014

    Hey man! can you tell me the value of your resistors you use? Thank you! 🙂

  17. Joana Marie08-12-2013

    very nice project sir! can you please send me the code sir? I would be very thankful sir.. please I badly need it sir..

  18. HAFIZ07-15-2013

    Hi…can u send me a code for this clock??

  19. chintu06-21-2013

    please send me the code for digital alarm clock

  20. mark12-16-2012

    great project mine is in developement. Working on alarm system to send gsm. all things working, just added clock, but could use your code to to able to set clock from keypad instead of serial.
    can you share your code yet.

    • Wai Hung12-16-2012

      I don’t have access to my computer now, I’ll post a section of my code later that uses the keypad to set the time.

      • mark12-20-2012

        Any luck with the code.

  21. Eric08-29-2012

    Hi Waihung,

    Great job in coding this. Working on something similar but with 4×4 keypad. Would you mind sharing your code? like the way you enter the new time with blinking cursor, but have troubles getting that coded.

    Thanks in advance

    • waihung08-29-2012

      Sorry I can’t give you the code because this is my actual college assignment. Hope you understand.

      On the other hand, to enable the blinking cursor, just use lcd.blink() and to disable it just use lcd.noBlink().
      The position of the blinking cursor can be set by using lcd.setCursor(column, row).

      Thanks 🙂

      • Eric08-31-2012

        No problem, understand.

        Would however like a small pointer how you collect the keystrokes. via string, or char??

        • waihung08-31-2012

          I collect it as char. Because I didn’t need the hash and asterisk, I can just take the char and minus 48. And the result is saved into int.

          According to the ASCII table, the character ‘0’ is actually 48 in decimal.

          • Eric08-31-2012

            Thanks, was on that route as well and will continue now.
            Good luck with your project…

            • waihung08-31-2012

              Thanks and good luck with yours too 🙂

          • http://www./12-30-2016

            Dear Carlos and all,I’m inspired by the idea of digging deeper not just to “do something” but to feel and live the motivation behind Jesus’s work. In my studies and prayer I feel like Jesus didn’t “will” or “force” anything. He simply lived good, God in every action. I feel like it’s almost so simple that we often miss it. His parables and experiences are not rocket science for me. They are just pure and simple Love expressed through action. Thanks for this reminder. :)Ian  |  

          • , every 5lbs is gonna be challenging, will need your help tho man, anything you can advise would be great.All the way!!!!!!!!! 30lbs here we come baby!!!

  22. vick07-29-2012

    This is awesome !!! So long time and effort in it !! Good job bro 🙂

  23. Jenson Ooi07-28-2012

    so the true amount you spent is? 😛

    • waihung07-29-2012

      Should be > 200 gua.
      Buy the programmer also RM20 already.
      Buy thinner, the dual layer PCB, broken drill bit, petrol money always go to Jalan Pasar.

Leave a Reply to KALYANKUMAR S Click here to cancel reply.