There are 3 statuses
1 heating start procedures,
2 Heating Stop procedures,
3 Error Locking
I've already tried various kinds of code's but don't get it working.
Go try it now with the switch case.
But help is very welcome now.
It is for a parking heater for my boat and has tremendous urgency now to limit the moisture damage.
Operation with LCD ECT comes later but the basics should work asap.
The code below is what I have now then you get an idea of the intent.
Now try another new one with the switch case in the meantime
float pressLength_milliSeconds = 0;
// Define the minimum length of time, in milli-seconds, that the button must be pressed for a particular option to occur
int optionOne_milliSeconds = 100;
int optionTwo_milliSeconds = 2000;
// Define error counter
int error = 0;
//The Pin your button is attached to
int startstop = 6;
int reset = 7;
int vlamschakelaar = 8;
int tempschakelaar = 9;
//Pin your LEDs are attached to
int ventilator = 5;
int gloeispiraal = 4;
int luchtklep = 2;
int brandstofpomp = 3;
int volhalfvermogen = 10;
void setup(){
// Initialize the pushbutton pin as an input pullup
// Keep in mind, when pin 2 has ground voltage applied, we know the button is being pressed
pinMode(startstop, INPUT_PULLUP);
pinMode(reset, INPUT_PULLUP);
pinMode(vlamschakelaar, INPUT_PULLUP);
pinMode(tempschakelaar, INPUT_PULLUP);
//set the stuur pins as outputs
pinMode(ventilator, OUTPUT);
pinMode(gloeispiraal, OUTPUT);
pinMode(luchtklep, OUTPUT);
pinMode(brandstofpomp, OUTPUT);
pinMode(volhalfvermogen, OUTPUT);
//Start serial communication - for debugging purposes only
Serial.begin(9600);
} // close setup
void loop() {
//Record roughly the tenths of seconds the button in being held down
while (digitalRead(startstop) == LOW ){
delay(100); //if you want more resolution, lower this number
pressLength_milliSeconds = pressLength_milliSeconds + 100;
//display how long button is has been held
Serial.print("ms = ");
Serial.println(pressLength_milliSeconds);
}//close while
//Different if-else conditions are triggered based on the length of the button press
//Start with the longest time option first
//Option 2 - Execute the second option if the button is held for the correct amount of time
if (pressLength_milliSeconds >= optionTwo_milliSeconds){
stop_proceduren();
}
}
//option 1 - Execute the first option if the button is held for the correct amount of time
else if(pressLength_milliSeconds >= optionOne_milliSeconds){
start_proceduren();
}
}//close if options
//every time through the loop, we need to reset the pressLength_Seconds counter
pressLength_milliSeconds = 0;
} // close void loop
void start_proceduren(){
digitalWrite(gloeispiraal, LOW);
Serial.print(gloeispiraal);
digitalWrite(brandstofpomp, LOW);
Serial.print(brandstofpomp);
digitalWrite(luchtklep, LOW);
Serial.print(luchtklep);
delay(120000);
digitalWrite(ventilator, LOW);
Serial.print(ventilator);
}
void stop_proceduren(){
digitalWrite(ventilator, HIGH);
Serial.print(ventilator);
delay(5000);
digitalWrite(gloeispiraal, HIGH);
Serial.print(gloeispiraal);
digitalWrite(luchtklep, HIGH);
Serial.print(luchtklep);
delay(16000);
digitalWrite(brandstofpomp, HIGH);
Serial.print(brandstofpomp);
delay(45000);
digitalWrite(gloeispiraal, LOW);
Serial.print(gloeispiraal);
}
void error_proceduren(){
Serial.print("error")
}