Arduino Based Digital Clock with Alarm
Arduino Based Digital Clock
with Alarm
This
Arduino based Real time clock is a digital clock to display real time
using a RTC IC DS1307which works on I2C protocol. Real time clock means it runs even after
power failure. When power is reconnected, it
displays the real time irespective to the time and duration it was in off state. In this project we have used a 16x2 LCD module to
display the time in - (hour, minute, seconds, date,
month and year)
format. An Alarm option is also added and we can set
up the alarm time.
Once alarm time it saved in
internal EEPROM of arduino, it remains saved even after reset or electricity
failure.
Real time clocks
are commonly used in our computers, houses, offices and electronics device
for keeping them updated with real time.
I2C
protocol is a method to connect two or more devices using two wires to a
single system, and so this protocol is also called as two wire
protocol.
It can be used to communicate
127 devices to a single device or processor. Most of I2C devices run on100Khz frequency.
Steps
for data writing master to slave (slave receiving mode)
- Sends START condition to slave.
- Sends slave address to slave.
- Send write bit (0) to slave.
- Received ACK bit from slave
- Sends words address to slave.
- Received ACK bit from slave
- Sends data to slave.
- Received ACK bit from slave.
- And last sends STOP condition to slave.
Steps
for data reading from slave to master (slave transmitting mode)
- Sends START condition to slave.
- Sends slave address to slave.
- Send read bit (1) to slave.
- Received ACK bit from slave
- Received data from slave
- Received ACK bit from slave.
- Sends STOP condition to slave.
Circuit Diagram and Description
In this
Arduino based digital clock circuit, we have used three major
components which are IC DS1307, Arduino Pro Mini Board and 16x2 LCD module.
Here
arduino is used for reading time from ds1307 and display it on 16x2 LCD. DS1307 sends time/date using 2 lines to arduino. A buzzer is also used for alarm indication, which
beeps when alarm is activated. A
block diagram is shown below to understand the working of this Real Time Clock.
As you
can see in the circuit diagram, DS1307 chip pin SDA and SCL are connected to
arduino pins SDA and SCL with pull up resistor that holds default value HIGH at
data and clock lines. 32.768KHz crystal oscillator is connected with
DS1307chip for generating exact 1 second delay, and a 3 volt battery is also
connected to pin 3rd (BAT) of DS1307 which keeps time running after
electricity failure.16x2 LCD is connected with
arduino in 4-bit mode. Control pin RS, RW and En are directly connected to arduino pin
2, GND and 3.
And data pin D0-D7 is connected to 4, 5, 6, 7 of arduino. A buzzer is connected with arduino pin number 13
through a NPN BC547 transistor having a 1 k resistor at its base.
Three
buttons namely set, INC and Next are used for setting alarm to pin 12, 11 and
10 of arduino in active low mode. When
we press set, alarm set mode activates and now we need to set alarm by using
INC button and Next button is used for moving to digit. The complete breadboard setup of this real
time clock with alarm is shown in below image. You can also check a detailed tutorial
on digital
alarm clock with AVR microcontroller.
Program Description
To
program for this real time clock, we have used some libraries for extracting
time/date from DS1307 and for displaying on LCD,
which are given below:
And
initialization of RTC, LCD and input output are performed in setup loop.
Rest
of things like reading time, setting alarm is performed in void loop section.
Demo & Code
Arduino Based Digital Clock with Alarm
Reviewed by XXX
on
สิงหาคม 27, 2560
Rating:
ไม่มีความคิดเห็น