Skip to content

Instantly share code, notes, and snippets.

@caseyanderson
Created July 28, 2020 21:31
Show Gist options
  • Save caseyanderson/45a4d98f28e3f8ada0eaa401811164d8 to your computer and use it in GitHub Desktop.
Save caseyanderson/45a4d98f28e3f8ada0eaa401811164d8 to your computer and use it in GitHub Desktop.
'''
button_mode.py
'''
from machine import Pin
from time import sleep
button = Pin(12, Pin.IN, Pin.PULL_UP)
mode = 0
while True:
if not button.value() and mode == 0:
print('Button pressed!')
print('do some stuff')
#
#
#
sleep(1) # change this number to allow more or less time for a person to notice the output
print("going to mode 1")
mode = 1
elif not button.value() and mode == 1:
print('Button pressed!')
print('do some stuff')
#
#
#
sleep(1) # change this number to allow more or less time for a person to notice the output
print("going back to mode 0")
mode = 0
sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment