const int potentiometerPin = A0; // Define the pin for the potentiometer
const int ledPins[] = {9, 10, 11};
void setup() {
// Serial.begin(9600); // Initialize serial communication for debugging
for (int i = 0; i < 3; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// Read the analog value from the potentiometer
int sensorValue = analogRead(potentiometerPin);
int voltage = map(sensorValue, 0, 1023, 10, 1000);
// Turn on the first LED and turn off the other two
for (int i = 0; i < 3; i++) {
// Turn on the current LED
digitalWrite(ledPins[i], HIGH);
// Turn off the other LEDs
for (int j = 0; j < 3; j++) {
if (j != i) {
digitalWrite(ledPins[j], LOW);
}
}
delay(voltage);
}
}