Led turn on when powereing up Nano

Hi, I am using a Nano to control my steering wheel buttons that used to be used for cruise control to control my Mustang's Tesla Model 3 motor instead of switches on the console.
My question is when powering up the Nano need to have my designated Park LED come on, go HIGH, and then have it go LOW when I activate the Park off, Drive, Reverse or Neutral and come back on when Park on is pressed again? I'm sure there is a way I'm just having the issue to turn it off. I can turn it on but then when I press say the Drive button the led goes off while it's pressed but comes back on. I need it to shut off until I press the Park button again or if the ignition is shut off then back on. It seems really simple but I'm having a mental block it seems with the logic. I have all functions working relays but having issues with the indicator lights. One of the issues is that all the motor controller inputs are momentary 12 volts to the M3 motor controller. Thus the relays. Here's the code.

/*
Send data from multiple steering wheel switches through a pair of wires without using a digital protocol only a program resistor is needed for each switch and an analog voltage from the resistor
is detected and momentary switch enable Rev Date 01-01-2022
*/
int commandState;
void setup() {
Serial.begin(9600);
pinMode (2, HIGH); // On button = Park setting in controller, Park brake enable. Relay #1:
pinMode (3, HIGH); // Set+ button = Drive setting in controller. Relay #3:
pinMode (4, HIGH); // Set- button = Reverse setting in controller Relay #4 :
pinMode (5, HIGH); // Off button = Park brake off Relay #5:
pinMode (6, HIGH); // Resume button = Neutral setting in controller. Relay #2:

pinMode (2, OUTPUT); // On button = Park setting in controller, Park brake enable. Relay #1:
pinMode (3, OUTPUT); // Set+ button = Drive setting in controller. Relay #3:
pinMode (4, OUTPUT); // Set- button = Reverse setting in controller Relay #4 :
pinMode (5, OUTPUT); // Off button = Park brake off Relay #5:
pinMode (6, OUTPUT); // Resume button = Neutral setting in controller. Relay #2:

}

void loop() {
commandState = analogRead(A0);
Serial.println(commandState);

  if(commandState >=150 && commandState <=210){
digitalWrite (2, HIGH);
digitalWrite (3, HIGH); //All pins HIGH this section:
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);

}
else if(commandState >=300 && commandState <=350){
digitalWrite (2, LOW); //Park brake On, motor in Park mode:
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);
digitalWrite (7, HIGH); //Test LED
}
else if(commandState >=450 && commandState <=530){
digitalWrite (2, HIGH);
digitalWrite (3, LOW);
digitalWrite (4, HIGH); //Resume = Neutral:
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);
}

else if(commandState >=610 && commandState <=650) {
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, LOW); //Set+ = forward drive enable:
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);
}
else if(commandState >=750 && commandState <=800) {
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH); //Set- = reverse drive enable:
digitalWrite (5, LOW);
digitalWrite (6, HIGH);

}
else if(commandState >=1000 && commandState <=1023) {
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (5, HIGH); //Off button = Park brake Off,
digitalWrite (6, LOW);
digitalWrite (7, LOW); //Test LED:
}
delay(50);
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Forgive me for asking, but are you talking about a toy, a game or a real car/automobile?

Hi, It is a 2006 Ford Mustang with a Tesla Model 3 motor conversion. Here's a video of the car.

What is your intent for these lines of code? PinMode can only be OUTPUT, INPUT, or INPUT_PULLUP.

It would be helpful to know what the definitions for the ranges of commandState are. I can sort of infer from the code but documenting the definitions explicitly would be helpful. Also, if you use descriptive constants for the pin numbers that would make the code more readable.

Your actual issue is that your code only considers the "current" state of commandState. In other words, all of your LEDs states are set solely based on the current commandState value. You need to "remember" the last state of the Park LED, for example, and when it should go on or off. I would suggest using a state machine. Here are some links that might be helpful:

State Machine

StateChangeDetection

Hi, Those first lines are totally wrong. They should be digitalWrite(2, HIGH); etc. My mistake, I would have thought the code should not have compiled but it did, weird, and it worked, even weirder. That will be fixed thank you.

I did figure out how to turn the LED on when powering up the nano.
pinMode(7, output)
digitalWrite(7, HIGH)

I had drove myself crazy yesterday for hours trying to figure this out. Then I picked up the Arduino Programming book and it was actually book marked where I stop reading it months ago and the answer was right there. 2 simple little lines of code.

So now it all works according to plan.

Thank you for taking a look and pointing out that mistake.