import machine
import time
from machine import UART
led = machine.Pin(2, machine.Pin.OUT)
uart = machine.UART(2, 115200)
strMsg=''
#Apagar y prender dose veces el led incluido en el esp32 para verificar
led.off()
time.sleep_ms(1000)
led.on()
time.sleep_ms(1000)
led.off()
time.sleep_ms(1000)
led.on()
time.sleep_ms(1000)
while True:
if uart.any() > 0:
strMsg= uart.read()
print(strMsg)
if 'on' in strMsg:
led.on()
uart.write('LED encendido')
print('Led on')
elif 'off' in strMsg:
led.off()
uart.write('LED Apagado')
print('Led off')
else:
uart.write('Comando Invalido')
print('Comando Invalido')
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4