EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #449 background imageLoading...
Page #449 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
motor2A = Pin(26, Pin.OUT)
# I2C LCD1602 setup
lcd = LCD()
# Rotate the pump
def rotate():
motor1A.value(1)
motor2A.value(0)
# Stop the pump
def stop():
motor1A.value(0)
motor2A.value(0)
button_state = False
# Define the button callback function to toggle the button state
def button_callback(pin):
global button_state
button_state = not button_state
# Attach the button callback function to the rising edge of the button pin
button.irq(trigger=Pin.IRQ_RISING, handler=button_callback)
page = 0
temp = 0
humi = 0
try:
while True:
# If the button is pressed and button state is True
if button_state:
print("rotate")
rotate()
# If the button is pressed again and button state is False
if not button_state:
print("stop")
stop()
time.sleep(2)
# Clear the LCD display
lcd.clear()
# Toggle the value of the page variable between 0 and 1
page=(page+1)%2
# When page is 1, display temperature and humidity on the LCD1602
if page is 1:
try:
(continues on next page)
3.40. 6.8 Plant Monitor 443

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish