She Matic
She Matic
import machine
from machine import Pin, SoftI2C, Timer
from lcd_api import LcdApi
from esp32_i2c_lcd import I2cLcd
from time import sleep
import dht
# LED setup
red = Pin(2, machine.Pin.OUT)
green = Pin(4, machine.Pin.OUT)
blue = Pin(5, machine.Pin.OUT)
except OSError as e:
print('Failed to read sensor.')
# Chương trình sẽ tiếp tục chạy mà không cần vòng lặp chính do Timer
đang chạy
while True:
sleep(1) # Giữ chương trình chạy đểTimer tiế p tục hoạt động
Bài 2
# Main loop
while True:
if mode == 0: # Simultaneous blinking
led_state = not led_state
for led in led_pins:
led.value(led_state)
time.sleep(0.5) # Change the blinking time of the LED here