const int pot1Pin = 34; // Potentiometer 1 connected to GPIO pin 34
const int pot2Pin = 35; // Potentiometer 2 connected to GPIO pin 35
const int redLEDPin = 2; // Red LED connected to GPIO pin 2
const int greenLEDPin = 0; // Green LED connected to GPIO pin 0
int pot1Value = 0;
int pot2Value = 0;
void setup() {
Serial.begin(115200);
pinMode(redLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
}
void loop() {
// Read potentiometer 1 value
pot1Value = analogRead(pot1Pin);
Serial.println("Potentiometer 1: " + String(pot1Value));
// Control red LED based on potentiometer 1 reading
if (pot1Value > 2000) {
digitalWrite(redLEDPin, HIGH);
} else {
digitalWrite(redLEDPin, LOW);
}
delay(500);
// Read potentiometer 2 value
pot2Value = analogRead(pot2Pin);
Serial.println("Potentiometer 2: " + String(pot2Value));
// Control green LED based on potentiometer 2 reading
if (pot2Value > 2000) {
digitalWrite(greenLEDPin, HIGH);
} else {
digitalWrite(greenLEDPin, LOW);
}
delay(500);
}