Now sends message on button press with debounce and toggle
This commit is contained in:
parent
d4def45508
commit
4985906a8c
17
main.py
17
main.py
@ -1,5 +1,7 @@
|
||||
import usocket as socket
|
||||
import ssl
|
||||
from machine import Pin
|
||||
import time
|
||||
|
||||
with open('token') as f:
|
||||
token = f.readline().strip('\n')
|
||||
@ -48,9 +50,20 @@ Content-Length: {content_length}\r
|
||||
|
||||
s.close()
|
||||
|
||||
def simple_msg():
|
||||
send_msg("Hello there from the button")
|
||||
|
||||
def main():
|
||||
send_msg("Hello there")
|
||||
|
||||
p2 = Pin(2, Pin.IN)
|
||||
while True:
|
||||
cur_value = p2.value()
|
||||
active = 0
|
||||
while active < 20:
|
||||
if p2.value() != cur_value:
|
||||
active += 1
|
||||
else:
|
||||
active = 0
|
||||
time.sleep_ms(1)
|
||||
simple_msg()
|
||||
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user