Arduino Tutorial 31# How to make 12 hour format clock (DS1302) with Arduino
ฝัง
- เผยแพร่เมื่อ 8 ก.พ. 2018
- Arduino Tutorial 31# How to make 12 hour format clock (DS1302) with Arduino
Scroll down for code.....
Please like & Subscribe for more videos
Real Time Clock (DS1302) library
www.rinkydinkelectronics.com/l...
LiquidCrystal_I2C library Github link
github.com/fdebrabander/Ardui...
I2C scanner to find out I2C address
playground.arduino.cc/Main/I2c...
If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.
LIST OF COMPONENT (affiliate links)
amzn.to/2fvSRJq (Arduino)
amzn.to/2gRFSiv (RTC DS1302)
amzn.to/2yBk7eT (LCD display)
amzn.to/2zg8aeX (I2C)
amzn.to/2wxPmWz (Breadboard)
amzn.to/2vJ3lvo (Jumper wire)
#include (Wire.h)
#include (LiquidCrystal_I2C.h) //instead of parenthesis () put angle bracket as TH-cam description does not allow angle bracket
// Set the LCD address to 0x3F for a 16 chars and 2 line display // note: it may be different for your LCD please find it.
LiquidCrystal_I2C lcd(0x3F, 16, 2);
#include (DS1302.h)
// Init the DS1302
DS1302 rtc(2, 3, 4);
// Init a Time-data structure
Time t;
void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(TUESDAY); // Set Day-of-Week to TUESDAY
rtc.setTime(23, 59, 50); // Set the time to 24hr format it will automatically take time according to AM/PM
rtc.setDate(06, 2, 2018); // Set the date to Febrauray 6th, 2018
// initialize the LCD
lcd.begin();
}
void loop()
{
// Get data from the DS1302
t = rtc.getTime();
lcd.setCursor(0, 0);
if (t.date(=9){
lcd.setCursor(0,0);
lcd.print("0");
lcd.setCursor(1,0);
lcd.print(t.date, DEC);
}
else {
lcd.print(t.date, DEC);}
lcd.setCursor(3, 0);
lcd.print(rtc.getMonthStr());
lcd.setCursor(12,0);
lcd.print(t.year, DEC);
lcd.setCursor(4,1);
{if (t.hour)=12){
lcd.setCursor(13,1);
lcd.print("PM");
lcd.setCursor(4,1);
t.hour = t.hour-12;
if (t.hour== 0) {
t.hour = 12; // Day 12 PM
}
if (t.hour(=9){
lcd.setCursor(4,1);
lcd.print("0");
lcd.setCursor(5,1);
lcd.print(t.hour, DEC);
}
else {
lcd.print(t.hour, DEC);}}
else { if(t.hour==0){
t.hour=12; // Night 12 AM
}
lcd.setCursor(13,1);
lcd.print("AM");
lcd.setCursor(4,1);
if (t.hour(=9){
lcd.setCursor(4,1);
lcd.print("0");
lcd.setCursor(5,1);
lcd.print(t.hour, DEC);
}
else {
lcd.print(t.hour, DEC);}} }
lcd.setCursor(6,1);
lcd.print(":");
lcd.setCursor(7,1);
if (t.min(=9){
lcd.setCursor(7,1);
lcd.print("0");
lcd.setCursor(8,1);
lcd.print(t.min, DEC);
}
else {
lcd.print(t.min, DEC);}
lcd.setCursor(9,1);
lcd.print(":");
lcd.setCursor(10,1);
if (t.sec(=9){
lcd.setCursor(10,1);
lcd.print("0");
lcd.setCursor(11,1);
lcd.print(t.sec, DEC);
}
else {
lcd.print(t.sec, DEC);}
delay (1000);
lcd.clear();
}
Thank you so much for your information. Your information is really through and I was able to complete to set up 12 format clock using DS1302 and 1602a LCD. As you comment I've changed lcd(0x3F) to (0x27) and worked safisfacorily. The only problem I found was that time counts form 6:30 pm after unpluged power supply though I put a battery to DS1302. However this is very minor problem so I don't care. Thanks again.
Thank you for providing an excellent video. I'm not using a1302 but with your information I am going to see if I can take what you have provided and apply that to my 3231.
Good working code. I modified the end of the Loop function a bit, commented out delay (1000); which could be cause seconds to skip and lcd.clear(); to eliminate flickering of the screen.
nice vids, keep them up!
Quite clear and easy to understand. Thanks Sir!
Hey, can you help me modify the code to work whit the ds1307 RTC , and seting the hour /min/sec whit push buttons please?
Very nice clock
Do you have code for atmel studio 7 in assembler language
Hocam selamlar.
7 segment display TM1637 would be fun for just time... not the date...
i am using the code given by u but my arduino software is giving errors. so tell me the right code or software version
hi, i try this codes, maybe something wrong or my side, please help: if (t.min(=9){
How to write the code without using LCD?
hello sir can i request?please create a tutorial about how to set time and date using the buttons please help me im a student thankyouu i using ds3231 rtc
can you add a little beep on completion of each hour. say hourly signal or sound.
Vai how do i do it with ds 3231 rtc
When i upload the code the lcd still shows nothing
no matching function for call to 'LiquidCrystal_I2C::begin()'
I can use any RTC Module , (Yes or No) *Particular This Project.
Hello can you make 20 time alarm clock with arduino