How to use a button to activate a program

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
mevero
Posts: 13
Joined: Mon Aug 30, 2021 12:59 pm

How to use a button to activate a program

Post by mevero » Thu Dec 02, 2021 8:45 am

This is a part of a program in Python
You can use this for send a message alarm, need you name it.
I try to use this in Micro-Python but it does not work !!

DO YOU KNOW A SOLUTION TO MAKE IT WORKS ??
.-.--.-.-.-..-.-.--..--..-.-.--.
def print_io_button_4():

# This is the Twilio part
message = client.messages.create(
to="+31xxxxxxxxxxxxx",
from_="+14xxxxxxxx",
body="TRIAL MESSAGE: IT IS URGENT PLEASE CALL !! ")

print("SMS is send")
print(message.sid)

# here knows the program what to do with..
# when the button is pressed

knop.when_pressed = print_io_button_4

mevero
Posts: 13
Joined: Mon Aug 30, 2021 12:59 pm

Re: How to use a button to activate a program

Post by mevero » Wed Dec 15, 2021 9:20 am

I found the solution somewhere on the internet and it woks !!!

exec(open('doorbell') .read())

Post Reply