Gavinthesheep735

Songster
Jun 22, 2017
75
100
112
alright i don't know if any of you can help because this is arduino text but here is my problem. I am trying to turn 2 relays on and off monitor them on the serial monitor and every thing seems to work except the serial monitor it prints the first command but as soon as the second command tries to print it stops printing the first command and prints the second only. Sorry I am new to this, here is my text

#include <DS3231.h>

int DoorRelay = 4;
int LightRelay = 5;
DS3231 rtc(SDA, SCL);
Time t;

const int OnHourDoor = 21;
const int OnMinDoor = 20;
const int OffHourDoor = 21;
const int OffMinDoor = 25;

const int OnHourLight = 21;
const int OnMinLight = 22;
const int OffHourLight = 21;
const int OffMinLight = 28;

void setup() {
Serial.begin(115200);
rtc.begin();
pinMode(DoorRelay, OUTPUT);
digitalWrite(DoorRelay, LOW);
pinMode(LightRelay, OUTPUT);
digitalWrite(LightRelay, LOW);
}

void loop() {
t = rtc.getTime();
Serial.print(t.hour);
Serial.print(" hour(s), ");
Serial.print(t.min);
Serial.print(" minute(s)");
Serial.println(" ");
delay (1000) ;

if(t.hour == OnHourDoor&& t.min == OnMinDoor){
digitalWrite(DoorRelay,HIGH);
Serial.println("Door Open");
}

else if(t.hour == OffHourDoor && t.min == OffMinDoor){
digitalWrite(DoorRelay,LOW);
Serial.println("Door Closed");
}
if(t.hour == OnHourLight&& t.min == OnMinLight){
digitalWrite(LightRelay,HIGH);
Serial.println("Light On");
}

else if(t.hour == OffHourLight && t.min == OffMinDoor){
digitalWrite(LightRelay,LOW);
Serial.println("Light Off");
}


hope you are able to help.
 

New posts New threads Active threads

Back
Top Bottom