#define LED_BUTTON_PIN 7

int ledPins[] = {LED_BUTTON_PIN, 6, 5, 4};
int buttonPin = 9;
int potPin = A5;
bool estadoBotao = 0;

void setup() {
  Serial.begin(9600);

  for(int i = 0; i < 4; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
  pinMode(buttonPin, INPUT);
}

void loop() {
  int potVal = analogRead(potPin);
  Serial.print("Valor do potenciômetro: ");
  Serial.println(potVal);

  while(digitalRead(buttonPin)) estadoBotao = 1;
  if(estadoBotao) {
    digitalWrite(LED_BUTTON_PIN, HIGH);
    delay(2000);
    digitalWrite(LED_BUTTON_PIN, LOW);
    estadoBotao = 0;
  }

  int isLedOn[] = {LOW, LOW, LOW};
  int countOn = map(potVal, 0, 1023, 0, 3);
  for(int i = 0; i < countOn; i++) {
    isLedOn[i] = HIGH;
  }

  for(int i = 1; i <= 3; i++) {
    digitalWrite(ledPins[i], isLedOn[i-1]);
  }
}
$abcdeabcde151015202530fghijfghij
$abcdeabcde151015202530fghijfghij