Code
Make a mini lamp with a button and a LED.
/*
keyestudio ESP32 Inventor Learning Kit
Project 13.2 Mini Lamp
http://www.keyestudio.com
*/
#define led
#define button 15
bool
ledState
=
false;
void
setup() {
// initialize digital pin PIN_LED as an output.
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
// the loop function runs over and over again forever
void
loop() {
if
(digitalRead(button)
button jitter is triggered, so 20ms is delayed to judge whether the button is equal
0.
delay(20);
8.5. Arduino Project
4
==
LOW) {
//When the button value is 0 for the first
//Delay 20ms
ESP32 Starter Kit
time,␣
to␣
(continues on next page)
91
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers