Code: Select all
screen /dev/ttyUSB 115200
By issuing in the console
Code: Select all
>>> import machine
>>> button = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)
>>> button.value()
Code: Select all
button.value()
Code: Select all
import machine
import time
button = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_UP)
while True:
first = button.value()
time.sleep(0.01)
second = button.value()
if first and not second:
print('Button pressed!')
elif not first and second:
print('Button released!')
another test is to stay at the >>> mode and paste the code. pressing the button nothing changes. CTRL-C exits and returns:
Code: Select all
...
Traceback (most recent call last):
File "<stdin>", line 7
SyntaxError: invalid syntax
i am missing something over here.