Hi all, I know this is simple, but I have been looking at this program too long and just don't see the answer. I have tried both while and if loops but neither checks the button continuously, only whenever it loops around to check the condition.
I need to have a button held to start a test, check 3v3, then ir_Test, etc., but if the button is released, I'd like to exit from the loop and go back to the else statement, clear all the outputs and wait for the button again.
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(testPoint6, HIGH);
digitalWrite(testPoint7, HIGH); // this needs to change to LOW for actual test, but is high for scope testing.....
digitalWrite(sw_12VDC, HIGH);
delay (500); // wait .5 seconds for 12 V to come up and board to start.
check3V3 ();
// should exit to else condition if button not pressed anymore
ir_Test ();
// should exit to else condition if button not pressed anymore
voltage_Conv_RED();
// should exit to else condition if button not pressed anymore
voltage_Conv_GRN();
// should exit to else condition if button not pressed anymore
} else {
// turn board and LEDs off until new board is inserted:
digitalWrite(testPoint6, LOW);
digitalWrite(testPoint7, LOW);
digitalWrite(sw_12VDC, LOW);
digitalWrite(led_ir_detect, LOW);
digitalWrite(13, LOW);
lcd.home (); // go home
lcd.clear(); // go home
lcd.print("Waiting...");
delay (1000); // stop fading on LCD
}
}