1xButton2xLEDs


'''
button_led.py

toggle between two LEDs via button press
'''

from machine import Pin
from time import sleep_ms

button = Pin(12, Pin.IN, Pin.PULL_UP)
led1 = Pin(27, Pin.OUT)
led2 = Pin(33, Pin.OUT)

while True:
    if not button.value():
        print("LED1 IS ON, LED2 IS OFF")
        led1.v...

Materials

Digital Input

button.py

'''
button.py
'''

from machine import Pin
from time import sleep_msx...

button terminology

  • State: on (connected, electrons can flow) or off (disconnected, electrons cannot flow)
  • Acutation: the physical action necessary to change the state of a switch / button i.e. push, slide, flip, rotate
  • Momentary: remain connected when actuated i.e. the push buttons are conne...

basic LED circuit

There are two different ways to wire up a basic LED circuit to ESP32 3V and GND

Hookup Pattern (1)

esp32-basic-led-circuit

  1. Connect ESP32 GND to a blue bus on the side of your breadboard
  2. Connect ESP32 3V to a red bus on the side of your breadboard
  3. Use a 220R (or similar) to run the 3...

Thonny Installation

We will use Thonny to interact with our ESP32 from our computer

  1. Navigate to the Thonny website here
  2. Download the appropriate version for your OS
  3. Run the installer, follow the prompts

Micropython Installation

Step 1

Windows11 MacOS

St

...