I am trying to make an automatic lock which stays open during different times and on different days. I want the door open Monday through Friday 8am to 5pm. On Saturdays and Sundays I want the door locked. I will be using an electric lock strike the + wire to pin 9 and - to ground on arduino. I am using an LED for development purposes for now because I don't have the lock yet. The code I have now works (stays open) for 8am to 5pm through the whole week but i want the door locked for Saturdays and Sundays. This is my code so far:
#include <Time.h>
#define doorPin 9
void setup() {
// put your setup code here, to run once:
pinMode(doorPin, OUTPUT); // Connected to relay to activate the door lock
setTime(10,1,1,6,7,2014);
}
void loop() {
if (hour()>=8 && hour()<=17){
digitalWrite(doorPin, HIGH);
}
else if (weekday()==1 || weekday()==7){
digitalWrite(doorPin, LOW);
}