I need to run one script file after short press of switch button and another one after long press.
GPIO pins that i'm using are 25 and 26.
I have managed to run this Python code and it works well for just one script:
Code: Select all
#!/bin/bash exec > >(tee -a /home/pi/Skripta/log.txt) exec 2>&1 echo Restart `date` sudo python - <<END import time import RPi.GPIO as gpio gpio.setmode(gpio.BCM) gpio.setup(7, gpio.IN, pull_up_down=gpio.PUD_UP) print "wait for 2 seconds" buttonReleased = True while buttonReleased: gpio.wait_for_edge(7, gpio.FALLING) buttonReleased = False for i in range(20): time.sleep(0.1) if gpio.input(7): buttonReleased = True break gpio.cleanup() END echo `date`. reboot... sudo sh pi/Desktop/script1.sh