I am trying to create a switch for two security cameras in my house. I've successfully made a program that automatically switches between the cameras every second but I would like to add more to it. My goal is to have a toggle switch that changes between automatically changing the cameras when the switch is off and being able to manually select the camera with a button when the switch is on. This is the first question I've posted on the forum so please excuse any mistakes I might make in forum etiquette. Here is the code I have so far.
/*
Timed Camera Switch
Switches camera inputs every 3 seconds
*/
// Pins 0,1 and 2 are going to control the relays for the cameras.
// Pins 5 and 6 are the switch and button
// assign names to the pins being used:
int stateswitch = 5;
int button = 6;
int frontcam = 0;
int backcam = 2;
void setup() {
// initialize the digital pins as an outputs.
pinMode(stateswitch, INPUT);
pinMode(button, INPUT);
pinMode(frontcam, OUTPUT);
pinMode(backcam, OUTPUT);
}
void loop() {
buttonState = digitalRead(stateswitch);
if (buttonState == HIGH) {
//This is where I need to know what to put!
}
else {
digitalWrite(frontcam, HIGH); // turn frontcam on
delay(1000); // wait for one seconds
digitalWrite(frontcam, LOW); // turn frontcam off
delay(25); // delay between camera switch
digitalWrite(backcam, HIGH); //turn backcam on
delay(1000); //wait for one seconds
digitalWrite(backcam, LOW); //turn backcam off
delay(25); // delay between camera switch
}
}