newbee needs help

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")
}

Is there a question?

Operation with LCD ECT comes later

LCDs don't cope well with electro-convulsive therapy.

Please remember to use code tags when posting code

I don't know what you want to do with "error locking" but here's something that seems to work on the serial console.

Warning: Not fully debugged. Use at your own risk. YMMV. etc etc

Part 1/2 (forum size limit; just copy paste them together...)

#define START_1     0
#define START_2     1

#define STOP_1      0
#define STOP_2      1
#define STOP_3      2
#define STOP_4      3

#define NUM_PROCEDURES              2

#define WAIT_FOR_BUTTON_RELEASE     0
#define WAIT_FOR_BUTTON_PRESS       1
#define TIME_BUTTON_RELEASE         2
#define WAIT_FOR_PROCEDURE          3
#define TIME_DEADTIME               4

void start_proceduren( void );
void stop_proceduren( void );

typedef void (*ProcFunc)();

typedef struct
    {
        unsigned long   minPress;
        unsigned long   maxPress;
        unsigned long   deadTime;
        ProcFunc        Func;
    }ProcedureTableStruct;

ProcFunc
    ActiveProcedure = NULL;
    
ProcedureTableStruct 
    ProcTable[] = 
        {
            {
                .minPress = 100ul,
                .maxPress = 600ul,
                .deadTime = 5000ul,             //5-seconds
                .Func = &start_proceduren
            },
            {
                .minPress = 2000ul,
                .maxPress = 2500ul,
                .deadTime = 10000ul,            //10-seconds
                .Func = &stop_proceduren
                
            }
        };

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;        

bool
    bcondHeater = false;
    
// Define error counter
int error = 0;
 
//The Pin your button is attached to
const int startstop = 6;
const int reset = 7;
const int vlamschakelaar = 8;
const int tempschakelaar = 9;
 
//Pin your LEDs are attached to
const int pinHeartBeatLED = 13;
const int ventilator = 5;
const int gloeispiraal = 4;
const int luchtklep = 2;
const int brandstofpomp = 3;
const 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);
    pinMode(pinHeartBeatLED, OUTPUT);
    digitalWrite( pinHeartBeatLED, LOW );

    //Start serial communication - for debugging purposes only
    Serial.begin(9600);                                     
 
} // close setup

void StartStopStateMachine( void )
{
    bool
        procMatched;
    byte
        i;
    int
        nowBtn,
        lastBtn;
    static unsigned long
        timeDeadTimeDelay,
        timeButtonStart;
    unsigned long
        timeButtonPressed;
    static byte
        stateSSSM = WAIT_FOR_BUTTON_RELEASE;

    switch( stateSSSM )
    {
        case    WAIT_FOR_BUTTON_RELEASE:
            if( digitalRead( startstop ) == HIGH )
                stateSSSM = WAIT_FOR_BUTTON_PRESS;
                        
        break;

        case    WAIT_FOR_BUTTON_PRESS:
            if( digitalRead( startstop ) == LOW )
            {              
                delay(10);
                if( digitalRead( startstop ) == HIGH )
                    stateSSSM = WAIT_FOR_BUTTON_RELEASE;
                else
                {
                    timeButtonStart = millis();
                    stateSSSM = TIME_BUTTON_RELEASE;
                }//else
            }//if
        break;

        case    TIME_BUTTON_RELEASE:
            if( digitalRead( startstop ) == HIGH )
            {
                timeButtonPressed = millis() - timeButtonStart;
                i=0;
                procMatched = false;
                do
                {
                    if( (timeButtonPressed >= ProcTable[i].minPress) &&
                            (timeButtonPressed <= ProcTable[i].maxPress) )
                    {
                        ActiveProcedure = ProcTable[i].Func;
                        timeDeadTimeDelay = ProcTable[i].deadTime;
                        stateSSSM = WAIT_FOR_PROCEDURE;
                        procMatched = true;
                                                    
                    }//if

                    i++;
                    
                }while( i<NUM_PROCEDURES && !procMatched );
                
                if( !procMatched )
                {
                    error_proceduren();
                    stateSSSM = WAIT_FOR_BUTTON_RELEASE;
                    
                }//if
                
            }//if
            
        break;

        case    WAIT_FOR_PROCEDURE:
            if( ActiveProcedure == NULL )
            {
                timeButtonStart = millis();
                stateSSSM = TIME_DEADTIME;
                
            }//if
        
        break;
        

        case    TIME_DEADTIME:
            if( (millis() - timeButtonStart) >= timeDeadTimeDelay )
            {
                Serial.println( "READY FOR ANOTHER COMMAND\n" );
                stateSSSM = WAIT_FOR_BUTTON_RELEASE;
                
            }//if
            
        break;

        default:
            stateSSSM = WAIT_FOR_BUTTON_RELEASE;
        break;
                
    }//switch
    
}//StartStopStateMachine

Part 2/2

OP, sorry I didn't have time to comment it. PM me if you have any questions.

void loop() 
{
    StartStopStateMachine();
    
    if( ActiveProcedure != NULL )
        (*ActiveProcedure)();

    BlinkLED();
    
} // close void loop

void BlinkLED( void )
{
    static int
        stateLED = LOW;
    static unsigned long
        timeAliveLED = millis();
    unsigned long
        timeNow;

    timeNow = millis();
    if( (timeNow - timeAliveLED) > 250ul )  
    {
        stateLED ^= HIGH;
        digitalWrite( pinHeartBeatLED, stateLED );

        timeAliveLED = timeNow;
    }//if

}//BlinkLED

void start_proceduren( void )
{
    static unsigned long
        timeStart;
    static byte
        stateStart = START_1;
        
    if( bcondHeater == true )
    {
        Serial.println( "\n\n*** Heater is already running! ***\n\n" );
        stateStart = START_1;
        ActiveProcedure = NULL;
        return;
        
    }//if
    
    switch( stateStart )
    {
        case    START_1:
            Serial.println( "START PROCEDURE:" );
            digitalWrite(gloeispiraal, LOW);
            Serial.println( "   - Glow Plug LOW" );//Serial.print(gloeispiraal);
            digitalWrite(brandstofpomp, LOW);
            Serial.println( "   - Fuel Pump LOW" );//Serial.print(brandstofpomp);
            digitalWrite(luchtklep, LOW);
            Serial.println( "   - Air Valve LOW" );//Serial.print(luchtklep);
            timeStart = millis();
            stateStart = START_2;
            
        break;

        case    START_2:
            if( (millis() - timeStart) > 120000ul )     //120000    2-minutes
            {
                digitalWrite(ventilator, LOW);
                Serial.println( "   - Ventilator LOW" );//Serial.print(ventilator);
                stateStart = START_1;
                Serial.println( "START PROCEDURE COMPLETE\n" );
                bcondHeater = true;
                ActiveProcedure = NULL;
                                
            }//if
            
        break;
        
    }//switch
       
}//start_proceduren

void stop_proceduren()
{
    static unsigned long
        timeStop;
    static byte
        stateStop = STOP_1;

    if( bcondHeater == false )
    {
        Serial.println( "\n\n*** Heater is already stopped! ***\n\n" );
        stateStop = STOP_1;
        ActiveProcedure = NULL;
        return;
        
    }//if
            
    switch( stateStop )
    {
        case    STOP_1:
            Serial.println( "STOP PROCEDURE:" );
            digitalWrite(ventilator, HIGH);
            Serial.println( "   - Ventilator HIGH" );//Serial.print(ventilator);
            timeStop = millis();
            stateStop = STOP_2;
        break;

        case    STOP_2:
            if( (millis() - timeStop) > 5000ul )
            {
                digitalWrite(gloeispiraal, HIGH);
                Serial.println( "   - Glow Plug HIGH" );//Serial.print(gloeispiraal);
              
                digitalWrite(luchtklep, HIGH);
                Serial.println( "   - Air Valve HIGH" );//Serial.print(luchtklep);
                timeStop = millis();
                stateStop = STOP_3;
                
            }//if
            
        break;

        case    STOP_3:
            if( (millis() - timeStop) > 16000ul )
            {
                digitalWrite(brandstofpomp, HIGH);
                Serial.println( "   - Fuel Pump HIGH" );//Serial.print(brandstofpomp);
                timeStop = millis();
                stateStop = STOP_4;
                
            }//if
            
        break;

        case    STOP_4:
            digitalWrite(gloeispiraal, LOW);
            Serial.println( "   - Glow Plug LOW" );//Serial.print(gloeispiraal);
            Serial.println( "STOP PROCEDURE COMPLETE\n" );
            stateStop = STOP_1;
            bcondHeater = false;
            ActiveProcedure = NULL;
            
        break;
        
        
    }//switch
    
}//stop_proceduren

void error_proceduren()
{
  Serial.println("*** Error: Unknown button press ***\n\n");
  
}//error_proceduren

Really super awesome. Now you've really helped me with it. From here I can work out something good.

Really thank you so much for this

Not thought to use and switch and void together in this