# ESP32 and Mycropython: Programming your Hardware
# Author: Mordechai Bar Natan
#
# Lesson 1: LED blink
# https://wokwi.com/projects/393344705211340801
#
# Remember:
# On a LED, the long leg is the anode (+). Connect it to pin #2.
# The short leg is the cathode (-). Connect it to GND.
#
# References
# https://docs.micropython.org/en/latest/library/machine.Pin.html
from machine import Pin
from time import sleep
# Use a LED with pin #2
red_led_pin = 2
red_led = Pin(red_led_pin, Pin.OUT)
# Switch the LED on for a second and then off for a second
while True:
red_led.value(1) # LED on
sleep(1)
red_led.value(0) # LED off
sleep(1)