int vr1 = 13;
int value1 =0;
int led1 = 16;
int led2 = 17;
int led3 = 5;
int led4 = 18;
void setup() {
Serial.begin(9600);
pinMode (led1, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
pinMode (led4, OUTPUT);
}
void loop() {
delay(100);
value1= analogRead(vr1);
Serial.println(value1);
if (value1 >=3500){
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 1);
digitalWrite(led4, 1);
} else if (value1 >=2500){
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 1);
digitalWrite(led4, 0);
}else if (value1 >=1500){
digitalWrite(led1, 1);
digitalWrite(led2, 1);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
}else if (value1 >=500){
digitalWrite(led1, 1);
digitalWrite(led2, 0);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
}else if (value1 >=0){
digitalWrite(led1, 0);
digitalWrite(led2, 0);
digitalWrite(led3, 0);
digitalWrite(led4, 0);
}
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4