Is it possible when you activate one of the two buttons, there start ( run) a file. ( in Micro-Python)
The system works with Twilio, a program that sends a SMS message to a mobile phone.
The system works already but only one message is programmed.
It is for a lady who sits in a wheelchair and when she feels only she hopes her husband has time to call her. But when its urgent she pressed button two. I made it with Python and a Raspberry Pi but when the power went down and returns you have to start the program again. The micro-controller with flash memory works always.
Here is an article I googled up on Pi autostart
https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/all
the bigger issue is are you running from an SD card or a USB flash drive. Power failures are a known reason for SD card failures, that is why I now only use USB flash drives.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Thanks for your answer, I am now interested how to make it with Micro-python.
After a lot off looking on internet I find the solution. First a program for two buttons and the code for the file: exec(open('my file.py').read()) Part of the buttons code :
from machine import Pin
led = Pin(5, Pin.OUT)
but1 = Pin(4, Pin.IN, Pin.PULL_UP)
but2 = Pin(14, Pin.IN, Pin.PULL_UP)
def debounce(pin):
prev = None
for _ in range(32):
current_value = pin.value()
if prev != None and prev != current_value:
return None
prev = current_value
return prev
def but1_callback(pin):
d = debounce(pin)
if d == None:
return
elif not d:
led.value(not led.value())
# print('wit')
exec(open('door.py').read())
repeating this for but2