Hello cookiesss
Welcome to the world's best Arduino forum ever.
Consider:
enum LedNames {Red,Green};
constexpr uint8_t LedPins[] {9,10}; // [port pin] -- -->|-- -- [GND]
constexpr uint8_t ButtonPin {A0}; // [port pin] -- [button] -- [GND]
void setup()
{
for (auto LedPin:LedPins) pinMode(LedPin,OUTPUT);
pinMode(ButtonPin,INPUT_PULLUP);
}
void loop()
{
digitalWrite(LedPins[Green],digitalRead(ButtonPin)?LOW:HIGH);
digitalWrite(LedPins[Red],digitalRead(LedPins[Green])?LOW:HIGH);
}
Have a nice day and enjoy coding in C++.