Sketch 10x DIY Button Prototype Sketches. 5 must be toggle, 5 must be momentary. All should be handmade with cardboard (or other similar prototyping substrate), conductive tape, and other common materials.

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...