Code: Select all
WARNING:root:Unexpected echo. Expected b'%Run -c $EDITOR_CONTENT\r\n', got b'You pressed the button!\r\n'
Code: Select all
import machine
from machine import Pin
import utime
import _thread
button = machine.Pin(9, machine.Pin.IN, machine.Pin.PULL_DOWN)
global pressed
pressed = False
def button_thread():
global pressed
while True:
if button.value() == 1:
pressed = True
print("You pressed the button!")
utime.sleep(0.01)
_thread.start_new_thread(button_thread, ())