ablab

Hello Readers, welcome to my Blog - A Blog For Bloggers By A Blogger. I'm Arun, an entrepreneur Blogger from India.

DS1307 RTC based Alarm Clock Designing with ATmega32 and LCD Display

9954
6
Mark as Favourite

An alarm clock is a clock that indicates a pre-set time by producing sound at that time. This functionality of digital clock is used to awaken people or remind them of something.

In this project, we will learn How to design a DS1307 Real Time Clock(RTC) based alarm clock with AVR ATmega32 microcontroller and LCD Displays in 12 hour format. Here, the system operates in two modes:- clock mode and alarm mode. In clock mode, the system will display the time, date and day in a 16X2 alphanumeric LCD and will scan the 4X4 Keypad to check whether the user wants to set the alarm time or not. If the key defined to set the alarm time(in our case A is used to set alarm time) is pressed, then the user will enter the alarm time with AM/PM through the 4X4 keypad and the set alarm time is stored in the internal EEPROM of the microcontroller. In alarm mode, the system displays time and compares the clock time with the set alarm time stored in internal EEPROM and if the clock time matches with the set alarm time, then a buzzer will make sound to indicate that the alarm time has reached. The user can turn Off the buzzer by pressing the predefined key of the 4X4 Keypad(in our case D is used).

The data communication between DS1307 RTC and AVR ATmega32 microcontroller takes place using TWI(Two Wire Interface) communication protocol. First, the DS1307 RTC needs to be initialized with second, minute, hour, AM/PM, date, month, year and day values for the system to work. The DS1307 RTC is initialized only once. We will initialize the DS1307 with the following values:- time- 11:0:0 PM, Date- 1/1/14 and day as Wednesday. You can change the initialization values according to your need by changing the initialization values in the DS1307 write section of the code. After initialization of DS1307 RTC, the AVR ATmega32 microcontroller will scan the 4×4 keypad to check whether A key of the keypad is pressed or not. When A is pressed, it means that the user wants to set the alarm time and the microcontroller enters into a loop. Now, the microcontroller will display “Enter Alarm Time” in 1st row of the alphanumeric LCD and it will read its internal EEPROM to display the previous alarm time in 2nd row of the LCD. After this, the user will enter the alarm time in hour, minute and second sequence using 0 to 9 keys of 4×4 keypad and value of each pressed key is displayed in the LCD. The alarm time format will be hh:mm:ss. After setting the hour, minute and second values of the alarm time, the user will the enter the AM/PM value through * and # key of keypad(* for AM and # for PM). During alarm time setting if any wrong key is pressed

then the user can press the C key to erase the wrong key value from the LCD. The C key act as backspace here. The entered alarm time values are stored in the internal EEPROM by the microcontroller. As soon as the user enters the AM/PM value, the microcontroller comes out of the alarm setting loop and it will display time, date and day in the 16X2 alphanumeric LCD.

When the A key is not pressed, the microcontroller reads the time, date and day values from the DS1307 RTC and it will display these values in the 16X2 alphanumeric LCD. The microcontroller will also check whether the alarm is set or not. If alarm is set then, microcontroller will read its internal EEPROM to get the alarm time and it will compare the alarm time with clock time continuously. When clock time matches with alarm time, the microcontroller will send the signal to buzzer to make sound. To turn off the buzzer, user can press the D key of the 4X4 keypad.

Softwares Required

Hardwares Required

Name Quantity
AVR Trainer Board-100 with ATmega32 1pc
AVR USB Programmer 1pc
12V, 1A DC SMPS Adaptor 1pc
EEPROM & RTC Board with AT24C02 1pc
RG1602A 16X2 Alphanumeric LCD Green 1pc
4X4 Keypad 1pc
1 to 1 Connector-Female to Female 6pc
10 to 10 FRC Female to Female Connector 4pc

Circuit Diagram

Video

Connection Guide

The step-by-step connection guide for DS1307 RTC based Alarm Clock Designing with ATmega32 and LCD Display is as follows

  • Steps - 1 ( 0f 12 )

    Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

  • Steps - 2 ( 0f 12 )

    Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

  • Steps - 3 ( 0f 12 )

    Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

  • Steps - 4 ( 0f 12 )

    Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

  • Steps - 5 ( 0f 12 )

    Connect the 4X4 Keypad header of 4X4 Keypad with PortA header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

  • Steps - 6 ( 0f 12 )

    Connect the EEPROM & RTC header of EEPROM & RTC with PortC header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

  • Steps - 7 ( 0f 12 )

    Connect the VCC, I/P & GND pins of Buzzer header with 5V header, PD3 pin of PortD header & GND header respectively in AVR Trainer Board-100 with a 1 to 1 Connectors.

  • Steps - 8 ( 0f 12 )

    Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

  • Steps - 9 ( 0f 12 )

    Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

  • Steps - 10 ( 0f 12 )

    Switch on the power with the help of Power Switch of AVR Trainer Board-100.

  • Steps - 11 ( 0f 12 )

    Download DS1307 RTC based Alarm Clock Designing with ATmega32 and LCD Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

  • Steps - 12 ( 0f 12 )

    Wait for some time(30 seconds) and delete or convert the code between DS1307 write section starts here and DS1307 write section ends here into comments in the C Program of the project and compile the code. After compilation, download the code

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 12 )

  • Connect PortB header with LCD data header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 12 )

  • Connect RS, RW & EN pins of LCD control header with PD0, PD1 & PD2 pins of PortD header respectively in AVR Trainer Board-100 with 1 to 1 Connectors.

    Steps - 3 ( 0f 12 )

  • Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board-100.

    Steps - 4 ( 0f 12 )

  • Connect the 4X4 Keypad header of 4X4 Keypad with PortA header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 12 )

  • Connect the EEPROM & RTC header of EEPROM & RTC with PortC header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 6 ( 0f 12 )

  • Connect the VCC, I/P & GND pins of Buzzer header with 5V header, PD3 pin of PortD header & GND header respectively in AVR Trainer Board-100 with a 1 to 1 Connectors.

    Steps - 7 ( 0f 12 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 8 ( 0f 12 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-AF Cable.

    Steps - 9 ( 0f 12 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 10 ( 0f 12 )

  • Download DS1307 RTC based Alarm Clock Designing with ATmega32 and LCD Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 11 ( 0f 12 )

  • Wait for some time(30 seconds) and delete or convert the code between DS1307 write section starts here and DS1307 write section ends here into comments in the C Program of the project and compile the code. After compilation, download the code

    Steps - 12 ( 0f 12 )

Post a Comment

    • jadeja divyaraj
      hex file an not download
      2016-09-20 19:40:04
      Reply
    • jadeja divyaraj
      i can not download hex file because it is give me some error .....
      2016-09-20 19:57:45
      Reply
    • jadeja divyaraj
      it show some error in proties time will be constant
      2016-09-29 19:30:26
      Reply
    • ImamMusthofa
      Sir, how to make day,week or month based alarm?. Thank you.
      2017-02-17 11:06:07
      Reply
    • ImamMusthofa
      Sir, how to make day,week or month based alarm?. Thank you.
      2017-02-17 11:06:17
      Reply
    • ImamMusthofa
      Sir, how to make day,week or month based alarm?. Thank you.
      2017-02-17 11:06:17
      Reply