Code
/*
keyestudio ESP32 Inventor Learning Kit
Project 21.2Sound Controlled LED
http://www.keyestudio.com
*/
int
sound
=
33;
//Define sound to IO33
int
led
=
25;
//Define led to IO25
void
setup(){
pinMode(led,OUTPUT);
}
void
loop(){
int
value
=
analogRead(sound);
if(value
>
100){
digitalWrite(led,HIGH);
delay(2000);
}
else{
digitalWrite(led,LOW);
}
}
8.5. Arduino Project
//Set IO25 to output
//Read analog value of IO33 and assign it to value
//Judge whether value is greater than 100
//If IO25 pin outputs high level, LED lights up
//If IO25 pin outputs low level, LED lights off
ESP32 Starter Kit
125
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers