eberspacher d5wz controller (ecu replacement)

I know this is an old thread, however it was the closest I could find that meets my requirements. I have put together the following sketch (very messy I know) I had it performing as expected within void setup tasks I only need to perform once, my problems came when I added the safety cutout features within void loop that need running continuously. Running on Simulator for Arduino app it moves correctly down the sketch, however when it gets to the end of void setup the sketch just stops and ignores everything within the loop regardless of button states. Anything obvious stick out to anyone ? Thanks in advance

const int buttonPin2 = 2; //Start Switch
const int buttonPin3 = 3; //Overheat Detector
const int buttonPin4 = 4; //Flame Sensor
const int buttonPin5 = 5; //Spare
const int FanPin =  10;      // the number of the LED pin
const int GlowPin =  11;
const int FuelPin =  12;
const int WaterPin =  13;
// variables will change:
int buttonState2 = 1;         // variable for reading the pushbutton status
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
void setup() {
  // initialize the LED pin as an output:
  pinMode(FanPin, OUTPUT);
  pinMode(GlowPin, OUTPUT);
  pinMode(FuelPin, OUTPUT);
  pinMode(WaterPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  pinMode(buttonPin5, INPUT);
  // check power status
  if (buttonState2 == HIGH) {
    // turn LED on:
    digitalWrite(FanPin, HIGH);
    delay(3000);
    digitalWrite(FanPin, LOW);
    digitalWrite(WaterPin, HIGH);
    digitalWrite(GlowPin, HIGH);
    digitalWrite(FuelPin, HIGH);
    delay(15000);
    digitalWrite(FanPin, HIGH);
   

  } else {
    // turn LED off:
    digitalWrite(FanPin, LOW);
  }
}

void loop() {
  // read the state of the pushbutton value:
  buttonState2 = digitalRead(buttonPin2); // Check power status
  buttonState3 = digitalRead(buttonPin3); //Check Overheat Detector
  buttonState4 = digitalRead(buttonPin4); //Check Flame Sensor
  buttonState5 = digitalRead(buttonPin5);
  // flameout
  if (buttonState4 == HIGH) {
    // turn fan on fuel off glowplug off:
    digitalWrite(FuelPin, LOW);
    digitalWrite(GlowPin, LOW);
    digitalWrite(FanPin, HIGH);
  } else {
    ;
  }


  //Overheat safety

  if (buttonState3 == HIGH) {
    // turn fan on fuel off glowplug off:
    digitalWrite(FanPin, HIGH);
    digitalWrite(FuelPin, LOW);
    digitalWrite(GlowPin, LOW);
  } else {
    ;
  }
  // power down
  if (buttonState2 == LOW) {
    // turn fan on fuel off glowplug off:
    digitalWrite(FuelPin, LOW);
    digitalWrite(GlowPin, LOW);
    digitalWrite(FanPin, HIGH);
  } else {
    ;
  }
}

andi968: however when it gets to the end of void setup the sketch just stops and ignores everything within the loop regardless of button states

How do you know?

Put in some Serial.print() statements so you can see what is happening.

...R

Using step into function which advances code one line at a time as soon as we reach void loop the sketch stops

andi968:
Using step into function which advances code one line at a time as soon as we reach void loop the sketch stops

I don’t use a simulator so I don’t have a step-into facility.

Just put in some Serial.print() statements so that you are simulating what a person with a real Arduino would do.

…R

const int buttonPin2 = 2; //Start Switch

It's silly to use the pin number in the name. Makes a real mess if you need to move the switch to a different pin. If you used names like startPin, overheatPin, etc. the comments wouldn't be needed AND when you read from a pin, you wouldn't need to refer to the comments to know what was connected to the pin.

You did a much better job on the output pins. Now, fix the input side.

else {
    ;
  }

Dumb. If you have nothing to do, leave the else statement out.

If your simulator fails to execute loop(), delete the stupid simulator software and test the code on real hardware. You can use LEDs to simulate output.