This function is crucial in order for the user to determine when the program is run. Followed this schematic minus the LED portion:
Here is the code, I put the function in the root directory:
import mraa
import time
import os
button = mraa.Gpio(20)
#set GPIO 20 to input mode
button.dir(mraa.DIR_IN)
while True:
print "P8 state:", button.read()
if (button.read() == 1):
os.system("python root/uploadersd.py")
break
time.sleep(1)
Currently running script in the top level with python root/button.py
Successfully monitors button with 1 sec scans then runs the upload script when the button is pressed. The plan is to now make this program run at start up so the device is automatically looking for that button press to start the upload.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.