#include <LiquidCrystal_I2C.h>
const int potPin = A0;
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int ledSzam = 8;
void setup() {
Serial.begin(115200);
for (int i = 0; i < ledSzam; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
int potErtek = analogRead(potPin);
Serial.print("Potenciométer érték: ");
Serial.println(potErtek);
int ledBekapcs = map(potErtek, 0, 1023, 0, ledSzam);
for (int i = 0; i < ledSzam; i++) {
if (i < ledBekapcs) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
}
delay(50);
}