0:00
Did you know that millions of people rely on digital clocks every day, but few realize
0:06
how simple it is to build their own? Imagine creating a clock tailored to your needs with just a few affordable components
0:13
Stick around and I'll show you how. To build this clock, you'll need just a few components, an Arduino board to act as the brain
0:19
of the project, a DS1302 real-time clock module, which ensures your clock is always accurate
0:26
a 3-volt battery for the RTC module, an I2C LCD display to show the time and date in a clear user-friendly format, a breadboard and some jumper
0:35
wires. Here's how it works. The DS-1302 module keeps track of time even when the Arduino is
0:40
powered off. Thanks to its battery backup, the Arduino fetches this data from the RTC and sends it to the
0:46
LCD for display. It's an efficient and reliable system that's easy to set up. Now let's move on to the
0:51
hardware setup. Connect the DS-1302 RTC module to your Arduino. Connect the RST pin of the DS-1302 to
0:59
to pin 5 on the Arduino. Connect the DAT pin to pin 6 Connect the CLK pin to pin 7 Power the module by connecting VCC to the 5V pin on the Arduino and GND to the GND pin Next connect the I2C LCD display to the Arduino
1:15
Connect the SDA pin of the LCD to the A4 pin on the Arduino
1:19
Connect the SCL pin to the A5 pin. Finally, connect VCC to the 5V pin and GND to GND
2:01
With the connections done we ready to program our Arduino Let take a closer look at the code that will bring our clock to life
2:21
First, we start by including the necessary libraries, wire.h, DS1302.h, and Liquid Crystal
2:28
underscore i2c.h. These libraries will allow our Arduino to communicate with the RTC module and the LCD display
2:35
Next, we initialize the DS-1302 R2R2. module by specifying the pins we'll be using for communication. We also initialize the I-2C-LCD display
2:44
The address for the display is 0X-27 and we're defining the number of columns and rows as 16 and 2, respectively
2:52
In the setup function, we start by initializing the LCD and configuring the RTC module. If it's your first time uploading the code, you'll need to set the initial date and time. This can be done by creating a time object and passing the values for year, month, day, hour, minute, second, and day of the week
3:08
To set the time you need to un the lines where the time object is created and where the time is set using RTC TimeT After uploading the code comment those lines out and upload the code again to ensure the time is set properly In the loop function we retrieve the current time from the RTC module and
3:25
display it on the LCD. The time is shown in a 12-hour format with an AM-PM indicator
3:32
The date is displayed on the second row of the LCD in the format DD-M-M-S-Y-Y-Y-Y-Y. The entire display
3:38
is updated every second, giving you a real-time clock display. Let's upload the code and see our
3:43
Arduino clock in action. The moment of truth comes when you power up the Arduino and see the time and date displayed
3:54
on the LCD for the first time. It's a satisfying accomplishment. The RTC module ensures that the time is accurate even if the Arduino is restarted or powered off
4:07
We've built a simple yet effective clock using Arduino, the DS-1302 RTC, and an I-DU320
4:11
RTC and an I2C LCD display showcasing its functionality step by step. If you enjoyed this tutorial
4:18
don't forget to like, share, and subscribe for more Arduino projects. Thanks for watching and