Yes exactly!
If the digitalRead part was culprit, I can now probably use HIGH and LOW again in the variable. That did not work before, therefore I went with the decimal values that seemed like a logical replacement for 0's or 1's.
I would like it to read the same signal at least 500ms before taking action, now it takes every ms of signal change. I have tried other output pins on the ECU already but there are a lot of wires running in the loom that might cause electrical interference.
Tested and (also) working! So in my case I probably got lucky that it worked before. It was only after the mentioning of no-op that I understood why it did. Thanks! Now I reached my limit for replies so can't reply until tomorrow.. But I will read!
// Digital I/O Pin Constants
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; //variable
int ecusignal; //variable
// Initialising pins
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);
digitalRead(ecusignal);
if((valvestatus) == LOW && (ecusignal) == HIGH){
digitalWrite(R1,HIGH);
digitalWrite(R2,LOW);
digitalWrite(ledPin,LOW);
delay(2000);
digitalWrite(R2,HIGH);
EEPROM.update(eeprom,HIGH);
valvestatus = HIGH;
}
if((valvestatus) == HIGH && (ecusignal) == LOW){
digitalWrite(R1,LOW);
digitalWrite(R2,HIGH);
digitalWrite(ledPin,HIGH);
delay(2000);
digitalWrite(R1,HIGH);
EEPROM.update(eeprom,LOW);
valvestatus = LOW;
}
}