I need to create a program that can turn on and off a series of LED's based on the current time in hours. I have tried to create a program that will do this but the LED's remain on when the current time parameters meet the requirement to shut off. Here is a copy of my code. Can anyone point out what I am doing wrong. Thanks!
#include <Time.h>
#include <TimeLib.h>
int ledPins[] = {2,3,4,5,6,7};
int pinCount = 6;
void setup() {
Serial.begin(9600);
for (int thisPin = 0; thisPin < pinCount; thisPin ++){
pinMode(ledPins[thisPin], OUTPUT);
}
}
void loop() {
time_t t = now();
if(hour(t) < 6 || hour(t) >= 20){
for (int thisPin = 0; thisPin < pinCount; thisPin ++){
digitalWrite(ledPins[thisPin], HIGH);
}
}
if(hour(t) >= 6 || hour(t) <8){
for (int thisPin = 0; thisPin < pinCount; thisPin ++){
digitalWrite(ledPins[thisPin], LOW);
}
}
}