I'm having a problem where set time and date don't work when I run the code. The LCD screen stays at 00:00:00 for time and 00.00.2000 for the date even when i change it on the rtc.setTime and rtc.setDate lines.
first uncomment the lines (if it is comment out), set the time & upload the code and again comment out those line (which i showed in video) then again upload the code.
Thank you for sharing your clock I want to make one but don't want to use the I2C backpack on the display so can I just connect the display to the Arduino please as I don't have that part, thank you for your time Bob in the UK
Hi Bob, I wrote code for you (without I2C alarm clock) (But didn't tested on hardware), let me know it is working for you or not. for connection LCD to Arduino you can see roboticadiy.com/how-to-make-counter-using-motion-detection-sensor-pir-with-lcd/ ========================================================== //code for without I2C alarm clock #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #include int Hour; int Min; int pset = 8; // pushbutton for setting alarm int phour = 9; // pushbutton for hour int pmin = 10; // pushbutton for minutes int pexit = 11; // pushbutton for exit of set alarm int buzzer = 6; int h; int m; int buttonforset = 0; // pushbutton state for setting alarm int buttonforhour = 0; // pushbutton state for hour int buttonformin = 0;// pushbutton state for minutes int buttonforexit = 0; // pushbutton state for exit of set alarm int activate=0; Time t; // Init the DS1302 DS1302 rtc(2, 3, 4); void setup() { pinMode(pset, INPUT); pinMode(phour, INPUT); pinMode(pmin, INPUT); pinMode(pexit, INPUT); // Set the clock to run-mode, and disable the write protection rtc.halt(false); rtc.writeProtect(false); // Setup LCD to 16x2 characters lcd.begin(16, 2); // The following lines can be commented out to use the values already stored in the DS1302 //rtc.setDOW(SATURDAY); // Set Day-of-Week to FRIDAY //rtc.setTime(10, 0, 0); // Set the time to 12:00:00 (24hr format) //rtc.setDate(11, 11, 2017); // Set the date to August 6th, 2010 } void loop() { if (activate == 0) { // Display time on the right conrner upper line lcd.setCursor(0, 0); lcd.print("Time: "); lcd.setCursor(6, 0); lcd.print(rtc.getTimeStr()); // Display abbreviated Day-of-Week in the lower left corner //lcd.setCursor(0, 1); //lcd.print(rtc.getDOWStr(FORMAT_SHORT)); // Display date in the lower right corner lcd.setCursor(0, 1); lcd.print("Date: "); lcd.setCursor(6, 1); lcd.print(rtc.getDateStr()); t = rtc.getTime(); Hour = t.hour; Min = t.min; buttonforset = digitalRead(pset); } // setting button pressed if (buttonforset == HIGH) { activate =1; lcd.clear(); } while(activate== 1){ lcd.setCursor(0,0); lcd.print("Set Alarm"); lcd.setCursor(0,1); lcd.print("Hour= "); lcd.setCursor(9,1); lcd.print("Min= "); buttonforhour = digitalRead(phour); // set hour for alarm if (buttonforhour == HIGH){ h++; lcd.setCursor(5,1); lcd.print(h); if (h>23){ h=0; lcd.clear(); } delay(100); } buttonformin = digitalRead(pmin); // set minutes for alarm if (buttonformin == HIGH){ m++; lcd.setCursor(13,1); lcd.print(m); if (m>59){ m=0; lcd.clear();} delay(100); } lcd.setCursor(5,1); lcd.print(h); lcd.setCursor(13,1); lcd.print(m); buttonforexit = digitalRead(pexit); // exit from set alarm mode if (buttonforexit == HIGH){ activate = 0; lcd.clear(); } } if (Hour== h && Min== m) { tone(6,400,300);} delay (500); }
well, what I mean is the format of rtc.setTime (12, 59, 00) 24hrs right? how to convert it to 12hrs. :) so it will show like this 12:59:59 ... 01:00:00, it always show like this 12:59:59....13:00:00
yes i understood what you are asking.. just minus 12 from hour. there is some flaws which we have to solve with coding. i will make video on that within this week.
@TheeLan Frost I am busy right now so i couldnt make video but i am sending code for you. it works fine i have tested it. // DS1302_Serial_Hard (C)2010 Henning Karlsen // web: www.henningkarlsen.com/electronics // // A quick demo of how to use my DS1302-library to // retrieve time- and date-date for you to manipulate. // // I assume you know how to connect the DS1302. // DS1302: CE pin -> Arduino Digital 2 // I/O pin -> Arduino Digital 3 // SCLK pin -> Arduino Digital 4 #include // 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); // Setup Serial connection Serial.begin(9600); // The following lines can be commented out to use the values already stored in the DS1302 rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY rtc.setTime(12, 59, 50); // Set the time to 12:00:00 (24hr format) rtc.setDate(18, 1, 2018); // Set the date to August 6th, 2010 } void loop() { // Get data from the DS1302 t = rtc.getTime(); // Send date over serial connection //Serial.print("Today is the "); Serial.print(t.date, DEC); Serial.print(": "); Serial.print(rtc.getMonthStr()); Serial.print(" :"); Serial.print(t.year, DEC); Serial.println("."); // Send Day-of-Week and time //Serial.print("It is the "); //Serial.print(t.dow, DEC); // Serial.print(". day of the week (counting monday as the 1th), and it has passed "); {if (t.hour>=12){ t.hour = t.hour-12; if (t.hour== 0) { t.hour = 12; } Serial.print(t.hour, DEC);} else { Serial.print(t.hour, DEC);} } Serial.print(" : "); Serial.print(t.min, DEC); Serial.print(" :"); Serial.print(t.sec, DEC); Serial.println(" ."); // Send a divider for readability //Serial.println(" - - - - - - - - - - - - - - - - - - - - -"); // Wait one second before repeating :) delay (1000); }
hi i tried this connection but it seems the only sound is operating well. My LCD does not show anything and i rechecked it a lot but it is just blank. what can i do with this problem?
do connection (except ultrasonic obviously) as shown in roboticadiy.com/arduino-tutorial-ultrasonic-sensor-counter-with-lcd/ and upload following code. #include #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #include int Hour; int Min; int pset = 8; // pushbutton for setting alarm int phour = 9; // pushbutton for hour int pmin = 10; // pushbutton for minutes int pexit = 11; // pushbutton for exit of set alarm int buzzer = 6; int h; int m; int buttonforset = 0; // pushbutton state for setting alarm int buttonforhour = 0; // pushbutton state for hour int buttonformin = 0;// pushbutton state for minutes int buttonforexit = 0; // pushbutton state for exit of set alarm int activate=0; Time t; // Init the DS1302 DS1302 rtc(2, 3, 4); void setup() { pinMode(pset, INPUT); pinMode(phour, INPUT); pinMode(pmin, INPUT); pinMode(pexit, INPUT); // Set the clock to run-mode, and disable the write protection rtc.halt(false); rtc.writeProtect(false); // Setup LCD to 16x2 characters lcd.begin(); // The following lines can be commented out to use the values already stored in the DS1302 //rtc.setDOW(SATURDAY); // Set Day-of-Week to FRIDAY //rtc.setTime(10, 0, 0); // Set the time to 12:00:00 (24hr format) //rtc.setDate(11, 11, 2017); // Set the date to August 6th, 2010 } void loop() { if (activate == 0) { // Display time on the right conrner upper line lcd.setCursor(0, 0); lcd.print("Time: "); lcd.setCursor(6, 0); lcd.print(rtc.getTimeStr()); // Display abbreviated Day-of-Week in the lower left corner //lcd.setCursor(0, 1); //lcd.print(rtc.getDOWStr(FORMAT_SHORT)); // Display date in the lower right corner lcd.setCursor(0, 1); lcd.print("Date: "); lcd.setCursor(6, 1); lcd.print(rtc.getDateStr()); t = rtc.getTime(); Hour = t.hour; Min = t.min; buttonforset = digitalRead(pset); } // setting button pressed if (buttonforset == HIGH) { activate =1; lcd.clear(); } while(activate== 1){ lcd.setCursor(0,0); lcd.print("Set Alarm"); lcd.setCursor(0,1); lcd.print("Hour= "); lcd.setCursor(9,1); lcd.print("Min= "); buttonforhour = digitalRead(phour); // set hour for alarm if (buttonforhour == HIGH){ h++; lcd.setCursor(5,1); lcd.print(h); if (h>23){ h=0; lcd.clear(); } delay(100); } buttonformin = digitalRead(pmin); // set minutes for alarm if (buttonformin == HIGH){ m++; lcd.setCursor(13,1); lcd.print(m); if (m>59){ m=0; lcd.clear();} delay(100); } lcd.setCursor(5,1); lcd.print(h); lcd.setCursor(13,1); lcd.print(m); buttonforexit = digitalRead(pexit); // exit from set alarm mode if (buttonforexit == HIGH){ activate = 0; lcd.clear(); } } if (Hour== h && Min== m) { tone(6,400,300);} delay (500); }
I tried to follow the link you sent but the 2,3,4,5, and 11 inputs are already occupied. Can I ask how else can I connect the LCD with not enough input pins.
hi, thanks for sharing. I looked at project page on roboticadiy.com/. I saw that " LCD screen connection with parallel connection at alarm-clock project and project diagram. but your program codes about I2C-LCD." can you share I2C-LCD library? thanks.
ZUBER ABBUNAVAR have you installed I2C library in your computer???. if you haven't added please add that library. roboticadiy.com/arduino-tutorial-how-to-connect-i2c-with-lcd/
Hi .. thanks very much for your video , but I have a problem during the compilation . The compiler was stopped in the line Time t; ( line 22) --error: no matching function for call to 'Time::Time()' .. could you please help to me
hi, what type of jumper wires did you use? m to m, f to f, or m to f? i need your reply, ASAP please.
thank you for your work ..now i have some idea for my pill box reminder :)
I'm having a problem where set time and date don't work when I run the code. The LCD screen stays at 00:00:00 for time and 00.00.2000 for the date even when i change it on the rtc.setTime and rtc.setDate lines.
first uncomment the lines (if it is comment out), set the time & upload the code and again comment out those line (which i showed in video) then again upload the code.
Hi, pls i need an alarm system that can set up to 5 alarms only, nothing added just for alarm purposes.
Can we make multiple alarm in code plz tell me
how can I add a stop button for the alarm buzzer to stop? it keeps going until a minute passes by...
Hi! Did you use only F/F and M/M jumper wires or you used the hybrid ones as well? (I mean the F/M ones)
I downloaded the library for the DS1302 and liquidcrystal_I2C, but i got error says that there is no matching for call to ‘liquidcrystal_I2C::begin()’
Thx I used ur idea for my test, helped me a lot
nice, i think i'm going to replace the speaker with a water pump tho, to make sure i get up
Did you ever end up doing this because I have a project for school and need to build a water alarm clock.
You are the best , your code is so simple and easy to understand. It really helped me a lot. Thank you man.
Glad to hear that!
how did you do the coding? mine is not working.
Which lines of code save the alarm status on ?
can i increase the alarm tone time?. mean,now it is just ringing 1min. i want increas it
Thank you for sharing your clock I want to make one but don't want to use the I2C backpack on the display so can I just connect the display to the Arduino please as I don't have that part, thank you for your time Bob in the UK
Hi Bob, I wrote code for you (without I2C alarm clock) (But didn't tested on hardware), let me know it is working for you or not. for connection LCD to Arduino you can see roboticadiy.com/how-to-make-counter-using-motion-detection-sensor-pir-with-lcd/
==========================================================
//code for without I2C alarm clock
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include
int Hour;
int Min;
int pset = 8; // pushbutton for setting alarm
int phour = 9; // pushbutton for hour
int pmin = 10; // pushbutton for minutes
int pexit = 11; // pushbutton for exit of set alarm
int buzzer = 6;
int h;
int m;
int buttonforset = 0; // pushbutton state for setting alarm
int buttonforhour = 0; // pushbutton state for hour
int buttonformin = 0;// pushbutton state for minutes
int buttonforexit = 0; // pushbutton state for exit of set alarm
int activate=0;
Time t;
// Init the DS1302
DS1302 rtc(2, 3, 4);
void setup()
{
pinMode(pset, INPUT);
pinMode(phour, INPUT);
pinMode(pmin, INPUT);
pinMode(pexit, INPUT);
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// Setup LCD to 16x2 characters
lcd.begin(16, 2);
// The following lines can be commented out to use the values already stored in the DS1302
//rtc.setDOW(SATURDAY); // Set Day-of-Week to FRIDAY
//rtc.setTime(10, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(11, 11, 2017); // Set the date to August 6th, 2010
}
void loop()
{
if (activate == 0) {
// Display time on the right conrner upper line
lcd.setCursor(0, 0);
lcd.print("Time: ");
lcd.setCursor(6, 0);
lcd.print(rtc.getTimeStr());
// Display abbreviated Day-of-Week in the lower left corner
//lcd.setCursor(0, 1);
//lcd.print(rtc.getDOWStr(FORMAT_SHORT));
// Display date in the lower right corner
lcd.setCursor(0, 1);
lcd.print("Date: ");
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());
t = rtc.getTime();
Hour = t.hour;
Min = t.min;
buttonforset = digitalRead(pset);
} // setting button pressed
if (buttonforset == HIGH) {
activate =1;
lcd.clear(); }
while(activate== 1){
lcd.setCursor(0,0);
lcd.print("Set Alarm");
lcd.setCursor(0,1);
lcd.print("Hour= ");
lcd.setCursor(9,1);
lcd.print("Min= ");
buttonforhour = digitalRead(phour); // set hour for alarm
if (buttonforhour == HIGH){
h++;
lcd.setCursor(5,1);
lcd.print(h);
if (h>23){
h=0;
lcd.clear(); }
delay(100);
}
buttonformin = digitalRead(pmin); // set minutes for alarm
if (buttonformin == HIGH){
m++;
lcd.setCursor(13,1);
lcd.print(m);
if (m>59){
m=0;
lcd.clear();}
delay(100);
}
lcd.setCursor(5,1);
lcd.print(h);
lcd.setCursor(13,1);
lcd.print(m);
buttonforexit = digitalRead(pexit); // exit from set alarm mode
if (buttonforexit == HIGH){
activate = 0;
lcd.clear();
}
}
if (Hour== h && Min== m) {
tone(6,400,300);}
delay (500);
}
Thank you, Bob
Please try to slow down the arranging part
We are mere beginners
@@ksraahul5430 Thanks for your valuable feedback. I was thinking, not to waste my audience time by useless clips. but you are right it is bit fast.
You can change playback speed to slower
Bhai aap ne ye circuit kaunse software se banaya hai
what kind of libraries i need?
Hello sir i have a problem in code the Time t; has error
no matching function for call to 'Time::Time()
please add the I2C library. thank you
hey bro can i make when i press button it trun alarm off i tried but it just wont turn off
Hey
Can i take a look at your code if it is alright with you.
Hi. Thank you for your work. How to make an alarm clock ring every day?
Hi. it will ring every day on exact same time...
Got a problem about the code it says that 'class DS1302' has no member named 'WriteProtect', how can i fix this?
What about using ds1307 instead of ds1302?
Yes, you can use ds1307. library and ds1307 connection will be changed.
Is more then 5 alarm can be set on this.
you can set any number of alarms.
Thanks
Hi, would this code and schematic work with the DS3231 if I included the library for it instead of the library for the DS1307? Thanks in advance!
yes it would work. but do changes according to DS3231 code.
Thanks for your work! Its running properly :) one thing, how to change 24hrs format to 12hrs format? :)
to convert 24hr to 12 hr format. you just have to minus 12 from hour, if you dont understand this, i will make a video on this soon :) ...
Robotica DIY thank yo for your response :) appreciated and I'm looking forward to your next vid.
well, what I mean is the format of rtc.setTime (12, 59, 00) 24hrs right? how to convert it to 12hrs. :) so it will show like this 12:59:59 ... 01:00:00, it always show like this 12:59:59....13:00:00
yes i understood what you are asking.. just minus 12 from hour. there is some flaws which we have to solve with coding. i will make video on that within this week.
@TheeLan Frost I am busy right now so i couldnt make video but i am sending code for you. it works fine i have tested it.
// DS1302_Serial_Hard (C)2010 Henning Karlsen
// web: www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1302-library to
// retrieve time- and date-date for you to manipulate.
//
// I assume you know how to connect the DS1302.
// DS1302: CE pin -> Arduino Digital 2
// I/O pin -> Arduino Digital 3
// SCLK pin -> Arduino Digital 4
#include
// 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);
// Setup Serial connection
Serial.begin(9600);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(12, 59, 50); // Set the time to 12:00:00 (24hr format)
rtc.setDate(18, 1, 2018); // Set the date to August 6th, 2010
}
void loop()
{
// Get data from the DS1302
t = rtc.getTime();
// Send date over serial connection
//Serial.print("Today is the ");
Serial.print(t.date, DEC);
Serial.print(": ");
Serial.print(rtc.getMonthStr());
Serial.print(" :");
Serial.print(t.year, DEC);
Serial.println(".");
// Send Day-of-Week and time
//Serial.print("It is the ");
//Serial.print(t.dow, DEC);
// Serial.print(". day of the week (counting monday as the 1th), and it has passed ");
{if (t.hour>=12){
t.hour = t.hour-12;
if (t.hour== 0) {
t.hour = 12;
}
Serial.print(t.hour, DEC);}
else { Serial.print(t.hour, DEC);} }
Serial.print(" : ");
Serial.print(t.min, DEC);
Serial.print(" :");
Serial.print(t.sec, DEC);
Serial.println(" .");
// Send a divider for readability
//Serial.println(" - - - - - - - - - - - - - - - - - - - - -");
// Wait one second before repeating :)
delay (1000);
}
hi i tried this connection but it seems the only sound is operating well. My LCD does not show anything and i rechecked it a lot but it is just blank.
what can i do with this problem?
Same as mine does it mean it must have a specific model lcd?
hey nice project, Bro I want to set two alarm for all day, please help me
UA-cam dakı arduıno vıdeolarının yuzde 80 ı neden Hintliler yapıyorlar ?
CODE IS NOT WORKING!!!!
bro my project was not alarm , whats the mistake?
Good tutorial. How can I modify the sketch to make it run with normal 16x2 LCD instead of I2C LCD.
Thanks.
do connection (except ultrasonic obviously) as shown in roboticadiy.com/arduino-tutorial-ultrasonic-sensor-counter-with-lcd/
and upload following code.
#include
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include
int Hour;
int Min;
int pset = 8; // pushbutton for setting alarm
int phour = 9; // pushbutton for hour
int pmin = 10; // pushbutton for minutes
int pexit = 11; // pushbutton for exit of set alarm
int buzzer = 6;
int h;
int m;
int buttonforset = 0; // pushbutton state for setting alarm
int buttonforhour = 0; // pushbutton state for hour
int buttonformin = 0;// pushbutton state for minutes
int buttonforexit = 0; // pushbutton state for exit of set alarm
int activate=0;
Time t;
// Init the DS1302
DS1302 rtc(2, 3, 4);
void setup()
{
pinMode(pset, INPUT);
pinMode(phour, INPUT);
pinMode(pmin, INPUT);
pinMode(pexit, INPUT);
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// Setup LCD to 16x2 characters
lcd.begin();
// The following lines can be commented out to use the values already stored in the DS1302
//rtc.setDOW(SATURDAY); // Set Day-of-Week to FRIDAY
//rtc.setTime(10, 0, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(11, 11, 2017); // Set the date to August 6th, 2010
}
void loop()
{
if (activate == 0) {
// Display time on the right conrner upper line
lcd.setCursor(0, 0);
lcd.print("Time: ");
lcd.setCursor(6, 0);
lcd.print(rtc.getTimeStr());
// Display abbreviated Day-of-Week in the lower left corner
//lcd.setCursor(0, 1);
//lcd.print(rtc.getDOWStr(FORMAT_SHORT));
// Display date in the lower right corner
lcd.setCursor(0, 1);
lcd.print("Date: ");
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());
t = rtc.getTime();
Hour = t.hour;
Min = t.min;
buttonforset = digitalRead(pset);
} // setting button pressed
if (buttonforset == HIGH) {
activate =1;
lcd.clear(); }
while(activate== 1){
lcd.setCursor(0,0);
lcd.print("Set Alarm");
lcd.setCursor(0,1);
lcd.print("Hour= ");
lcd.setCursor(9,1);
lcd.print("Min= ");
buttonforhour = digitalRead(phour); // set hour for alarm
if (buttonforhour == HIGH){
h++;
lcd.setCursor(5,1);
lcd.print(h);
if (h>23){
h=0;
lcd.clear(); }
delay(100);
}
buttonformin = digitalRead(pmin); // set minutes for alarm
if (buttonformin == HIGH){
m++;
lcd.setCursor(13,1);
lcd.print(m);
if (m>59){
m=0;
lcd.clear();}
delay(100);
}
lcd.setCursor(5,1);
lcd.print(h);
lcd.setCursor(13,1);
lcd.print(m);
buttonforexit = digitalRead(pexit); // exit from set alarm mode
if (buttonforexit == HIGH){
activate = 0;
lcd.clear();
}
}
if (Hour== h && Min== m) {
tone(6,400,300);}
delay (500);
}
Robotica DIY Thank you it works perfectly. I had to tweak the code a little bit, but I can now run it with DS3231 RTC.
I tried to follow the link you sent but the 2,3,4,5, and 11 inputs are already occupied. Can I ask how else can I connect the LCD with not enough input pins.
very good job bro ,it super
hi, thanks for sharing.
I looked at project page on roboticadiy.com/. I saw that " LCD screen connection with parallel connection at alarm-clock project and project diagram. but your program codes about I2C-LCD." can you share I2C-LCD library? thanks.
What if I don’t have an I2C?
Hi
I need help if you can attach the code to a download link that will help me a lot
My problem is push buttons not working
Code is not working
Hey in code its showing error that"no matching function for call to 'LiquidCrystal _I2C::begin() please help
ZUBER ABBUNAVAR have you installed I2C library in your computer???. if you haven't added please add that library. roboticadiy.com/arduino-tutorial-how-to-connect-i2c-with-lcd/
@@RoboticaDIY I installed it but I still get the error
thank you very much.
Can you share the code ?
İf I don't i2c what can ı do??
connect LCD with wires, you can see some of my videos i did without I2C. connect wires according to that. some changes require in code also.
Programming not working
Hi .. thanks very much for your video , but I have a problem during the compilation . The compiler was stopped in the line Time t; ( line 22) --error: no matching function for call to 'Time::Time()' .. could you please help to me
I think you haven't installed DS1302 library. link for that library is mentioned in the description.
NOT RUN CODE
some time copy and paste causes error. try to write it yourself by looking at this code.
// Setup LCD to 16x2 characters
lcd.begin();
Thanks
plz help me
Halp me for ds3231 thanks thanks!!!