print("Hello, ESP32!")
from machine import Pin
from time import sleep
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
pin_LED = Pin (0, Pin.OUT)
pin_PB = Pin(14, Pin.OUT)
slide_pin = Pin(27, Pin.IN)
sda = Pin(21)
scl = Pin(22)
while True:
pin_LED.off()
val_PB = pin_PB.value()
print (val_PB)
if val_PB == 1:
pin_LED.on(),
sleep(0.1)
# I2C setup for LCD
I2C_ADDR = 0x27 # Default I2C address for 2004 LCD
i2c = I2C(0, sda=Pin(21), scl=Pin(22), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, 4, 20) # 4 rows and 20 columns
# Slide switch setup
switch = Pin(27, Pin.IN, Pin.PULL_UP) # Connect one pin of the switch to GPIO18
def display_message():
if switch.value() == 0: # When the switch is ON (connected to GND)
lcd.clear()
lcd.putstr("HI")
else:
lcd.clear() # Clear the display when switch is OFF
lcd.clear() # Clear LCD at the start
lcd.putstr("Slide switch test")
sleep(2)