Hello.
I have made sketch for controlling a chicken coop door (DC-motor pulls a string) based on lightreadings. The door brakes when it reaches the reed switches installed in top and bottom of the doorway.
So the final touch i want to do is ad two switches, the first one controlles if the system shold work automatic from the light readings or go to manual mode. The second switch is goeing to, if the first switch is set to manual, open or close the door deoending which way the switch is flipped.
everything works fine if the first switch is set to automatic. but when it is set to override, it goes and opens the door, regardless of the second switch position.
It was so simple when i made it work controlling leds, but now Im in trouble. Help is much appreciated ![]()
/*
// ************************************** the loop **************************************
void loop() {
delay (1000);
//debounceOverrideSwitch(); //read and debounce override switch
// debounceManualSwitch();
int overrideSwitchPinState = digitalRead (overrideSwitchPin);
Serial.println("Override Switch: ");
Serial.print (overrideSwitchPinState);
Serial.println();
if (overrideSwitchPinState == 0) { //the switch position is not flipped = 0, the system is automatic mode
doReadPhotoCell();
readPhotoCell();
doCoopDoor();
}
if (overrideSwitchPinState == 1) { //the switch position is flipped and the system goes into manual override
int manuelSwitchPinState = digitalRead (manuelSwitchPin);
Serial.println("Manuel Switch: ");
Serial.print (manuelSwitchPinState);
Serial.println();
if (manualSwitchPinState == 1) //the manual switch is in position 1
{
closeCoopDoorMotorB();
}
if (manualSwitchPinState == 0) //the manual switch is in position 0
{
openCoopDoorMotorB();
}
}
}