Sure! To modify the code to display time in 24-hour format, you can remove the logic for determining AM/PM and adjust the code to directly print the t.hr value as the hour. You can try this: void loop() { Time t = rtc.time(); // Display the time in 24-hour format lcd.setCursor(0, 0); lcd.print("Time "); if (t.hr < 10) lcd.print("0"); // Add leading zero if hour is less than 10 lcd.print(t.hr); lcd.print(":"); if (t.min < 10) lcd.print("0"); // Add leading zero if minutes are less than 10 lcd.print(t.min); lcd.print(":"); if (t.sec < 10) lcd.print("0"); // Add leading zero if seconds are less than 10 lcd.print(t.sec);
The I2C LCD and Wire libraries may not have been installed, or there could be a conflict with another installed LCD library. Check this article on how to download and install the libraries: www.arduinointro.com/articles/projects/displaying-characters-using-the-i2c-liquid-crystal-display-lcd
@arduinointrochannel Thank you for your respond then, what's the name of the library you install for this project? , i've already installed lcd 12c built in officially by arduino 1.0.7 isnt that the right library? And what's the name of wire library you use?
It's a fun project to learn about real-time clocks and I2C communication. Plus, you can customize or scale it to fit your project needs like an automated gardening system where you can turn on/off grow lights or water pumps at certain times or specific days (using conditional logic), or you can use it to make a log, with a date and time stamp, of anything that is captured by sensors connected to this Arduino setup. Think of this as a foundation of the greater things you can do with creativity and innovation.
Good video
Thanks!
Thanks for the explanation, very clear!
But in Europe (Holland) we use a 24-hour clock.
Do you have a solution for that?
Greetings
Leo
Sure! To modify the code to display time in 24-hour format, you can remove the logic for determining AM/PM and adjust the code to directly print the t.hr value as the hour. You can try this:
void loop() {
Time t = rtc.time();
// Display the time in 24-hour format
lcd.setCursor(0, 0);
lcd.print("Time ");
if (t.hr < 10) lcd.print("0"); // Add leading zero if hour is less than 10
lcd.print(t.hr);
lcd.print(":");
if (t.min < 10) lcd.print("0"); // Add leading zero if minutes are less than 10
lcd.print(t.min);
lcd.print(":");
if (t.sec < 10) lcd.print("0"); // Add leading zero if seconds are less than 10
lcd.print(t.sec);
i have a problem with the lcd initialize "POSITIVE wasnt declared in this scope",
can you help me sir ?
The I2C LCD and Wire libraries may not have been installed, or there could be a conflict with another installed LCD library. Check this article on how to download and install the libraries: www.arduinointro.com/articles/projects/displaying-characters-using-the-i2c-liquid-crystal-display-lcd
@arduinointrochannel Thank you for your respond then, what's the name of the library you install for this project? , i've already installed lcd 12c built in officially by arduino 1.0.7 isnt that the right library?
And what's the name of wire library you use?
cool but what dose it do that a 15$ clock cant in honesty a 15$ has am/fm and alarms so whatthe point of this just to show or is there more to this
It's a fun project to learn about real-time clocks and I2C communication. Plus, you can customize or scale it to fit your project needs like an automated gardening system where you can turn on/off grow lights or water pumps at certain times or specific days (using conditional logic), or you can use it to make a log, with a date and time stamp, of anything that is captured by sensors connected to this Arduino setup. Think of this as a foundation of the greater things you can do with creativity and innovation.