case 2)
int VALVE_switch = 9; //digital signal pin
int value; //variable to store the value of digital signal pin
void loop() {
if(digitalRead(value) == HIGH){
...
}
const int VALVE_switch = 9; //digital signal pin
int value; //variable to store the value of digital signal pin
void loop() {
value = digitalRead(VALVE_switch);
if(value == HIGH){
The choice is between: case 1)
if(digitalRead(Pin) == HIGH) {
or case 2)
int value = digitalRead(Pin);
if(value == HIGH) {
Use case 2 if you need to test the same state of the pin more than once. Use case 1 if you only look at the pin once in loop() OR IN A 'while' LOOP:
while (digitalRead(Pin) == HIGH) {
If you are using a 'while' loop to repeat something as long as the input pin is in a certain state you MUST re-read the input pin each time or you will never see a change.