OK, I see everyone just getting over the no-op lines.
Here's the code without it. I can see that it would work and do something.
const int S1 = 2; // Control input
const int R1 = A1; // Relay R1
const int R2 = A2; // Relay R2
#include <EEPROM.h>
int eeprom = 0;
int ledPin = 13;
int valvestatus;
int ecusignal;
void setup() {
valvestatus = EEPROM.read(eeprom);
pinMode(S1, INPUT_PULLUP);
pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(R1, HIGH);
digitalWrite(R2, HIGH);
}
void loop() {
ecusignal = digitalRead(S1);
if (valvestatus == 0 && ecusignal == HIGH) {
digitalWrite(R1, HIGH);
digitalWrite(R2, LOW);
digitalWrite(ledPin, LOW);
delay(2000);
digitalWrite(R2, HIGH);
EEPROM.update(eeprom, 255);
valvestatus = 255;
}
if (valvestatus == 255 && ecusignal == LOW) {
digitalWrite(R1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(ledPin, HIGH);
delay(2000);
digitalWrite(R1, HIGH);
EEPROM.update(eeprom, 0);
valvestatus = 0;
}
}
As for your fix, it might be a fix. On the other hand, there could be hardware issues that could also be addressed.
a7