// Пины для светодиодов
const int redLed = 9;
const int purpleLed = 10;
const int greenLed = 11;
const int yellowLed = 12;
const int blueLed = 13;
// Пин для потенциометра
const int potPin = A0;
void setup() {
// Настройка пинов светодиодов на вывод
pinMode(redLed, OUTPUT);
pinMode(purpleLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
pinMode(blueLed, OUTPUT);
}
void loop() {
// Чтение значения с потенциометра
int potValue = analogRead(potPin);
// Управление светодиодами в зависимости от значения потенциометра
if (potValue < 205) {
digitalWrite(redLed, HIGH);
} else {
digitalWrite(redLed, LOW);
}
if (potValue >= 205 && potValue < 410) {
digitalWrite(purpleLed, HIGH);
} else {
digitalWrite(purpleLed, LOW);
}
if (potValue >= 410 && potValue < 615) {
digitalWrite(greenLed, HIGH);
} else {
digitalWrite(greenLed, LOW);
}
if (potValue >= 615 && potValue < 820) {
digitalWrite(yellowLed, HIGH);
} else {
digitalWrite(yellowLed, LOW);
}
if (potValue >= 820) {
digitalWrite(blueLed, HIGH);
} else {
digitalWrite(blueLed, LOW);
}
}