ESP32 Starter Kit
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 4
#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) == LOW) { //When the button value is 0 for the first time,␣
˓→button jitter is triggered, so 20ms is delayed to judge whether the button is equal to␣
˓→0.
delay(20); //Delay 20ms
(continues on next page)
8.5. Arduino Project 91