SunFounder ESP32 Starter Kit
(continued from previous page)
if button.value() == 1:
# Turn on the LED by setting its value to 1
led.value(1)
# time.sleep(0.5)
else:
# Turn off the LED
led.value(0)
During script execution, the LED lights up when you press the button and goes out when you release it.
3.20 5.2 Tilt It
The tilt switch is a simple yet effective 2-pin device that contains a metal ball in its center. When the switch is in an
upright position, the two pins are electrically connected, allowing current to flow through. However, when the switch
is tilted or tilted at a certain angle, the metal ball moves and breaks the electrical connection between the pins.
In this project, we will utilize the tilt switch to control the illumination of an LED. By positioning the switch in a way
that triggers the tilt action, we can toggle the LED on and off based on the switch’s orientation.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name ITEMS IN THIS KIT LINK
ESP32 Starter Kit 320+
You can also buy them separately from the links below.
COMPONENT INTRODUCTION PURCHASE LINK
ESP32 WROOM 32E
ESP32 Camera Extension -
Breadboard
Jumper Wires
Resistor
LED
Tilt Switch -
Available Pins
• Available Pins
Here is a list of available pins on the ESP32 board for this project.
3.20. 5.2 Tilt It 359