Keyestudio ESP32 Manual page 129

Starter kit
Hide thumbs Also See for ESP32:
Table of Contents

Advertisement

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

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32 and is the answer not in the manual?

Questions and answers

Related Products for Keyestudio ESP32

Table of Contents

Save PDF