Now sends message on button press with debounce and toggle

This commit is contained in:
thepenguin 2023-03-23 22:37:43 +01:00
parent d4def45508
commit 4985906a8c
No known key found for this signature in database
GPG Key ID: F258C8C10D060D5E

17
main.py
View File

@ -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()