Here's your code for posterity, in code tags and reformatted using black:
Code: Select all
# Program for working with two buttons.
# Date: october 2022
# Creat : Wim van der Leek with help from a menber of raspberrystore.nl
import machine
from machine import Pin
import time
# On which pin are the led
led1 = machine.Pin(5, machine.Pin.OUT)
led2 = machine.Pin(4, machine.Pin.OUT)
# On which pin are the buttons
btn1 = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
btn2 = machine.Pin(3, machine.Pin.IN, machine.Pin.PULL_UP)
btn1_prev = btn1.value()
btn2_prev = btn2.value()
while True:
if (btn1.value() == 1) and (btn1.value() != btn1_prev):
btn1_prev = (
btn1.value()
) # Reminber the last state, for if someone who pressed the butoon continius.
# Calling Twilio for sending a SMS, which is not URGENT
led1.value(1)
exec(open("MessageNOR.py").read())
time.sleep(1)
led1.value(0)
if (btn2.value() == 1) and (btn2.value() != btn2_prev):
btn2_prev = btn2.value()
# Calling Twilio for sending a SMS, It is very urgent.
led2.value(1)
exec(open("MessageUR.py").read())
time.sleep(1)
led2.value(0)
btn1_prev = btn1.value()
btn2_prev = btn2.value()
time.sleep(0.1)