Hello guys so i finaly desided that i want to learn arduino… so i had some parts laying arround … so i first what i did i got my rtc ds3231 connected to arduino then my lcd screen ywrobot lcm1602c and then i was trying to get something like if time is 20:00 turn relay off or on but i kinda fail’d with that ! I found some people asking about the same question but what i found is that they use different rtc and differnet library even try’d other library but that didnt help too! so maybe someone knows how its done the right way with this library ?!
Right now my sketch looks like this its only displaying time on screen
#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // Using version 1.2.1
// The LCD constructor - address shown is 0x27 - may or may not be correct for yours
// Also based on YWRobot LCM1602 IIC V1
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
DS3231 rtc(SDA, SCL);
void setup()
{
Serial.begin(115200);
Wire.begin();
rtc.begin();
lcd.begin(16,2); // sixteen characters across - 2 lines
lcd.backlight();
pinMode(4, OUTPUT);
}
void loop()
{
lcd.setCursor(12,0); //Display Time On LCD Right Upper corner !
lcd.print(rtc.getTimeStr()); //---------------////--------------------
// Wait one second before repeating :)
delay (1000);
}
all what i want is just when time hits 20:00 it turns off my Relay and when its 7:00 its turns it back on !
i try’d something like
#define LED1 7
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 rtc;
DateTime now = rtc.now();
void setup()
{
Serial.begin(9600);
pinMode(LED1, OUTPUT);
}
void loop()
{
DateTime now = rtc.now();
if(now.hour() == 24)
digitalWrite(LED1,0); // Turns ON LED 1
Serial.println("Light ON");
delay(2000); // Wait 2 seconds
digitalWrite(LED1,1); // Turns OFF LED 1
Serial.println("Light OFF");
delay(2000);
}/code]
but didnt work because my library what i use dont have something like DateTime now = rtc.now();
it seems that it works with no problem for DS1307 rtc..
i have add a zip file with my library what i use ..