-
Notifications
You must be signed in to change notification settings - Fork 288
Switch controller installation
SecGroundZero edited this page Jul 1, 2016
·
5 revisions
If you want to manually choose when the scripts to start running you can implement a hardware toggle switch.
I drilled a small hole on the top of the casing to fit the switch as shown below.
Create the switch controller script. Change the pins and script location according to your setup. On the RPi3 i have the switch connected to PIN6 and PIN16 which correspond to GND and BCM23.
#!/usr/bin/env python2.7
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BCM)
import os
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
try:
GPIO.wait_for_edge(23, GPIO.FALLING)
subprocess.call("sudo python warberry.py", shell = True)
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()
Create a controller bash script to call the switch script
#!/bin/sh
cd /home/pi/WarBerry/warberry/
sudo python switch.py
Save the script as start.sh
Edit /etc/rc.local and add the line
sudo bash /home/pi/WarBerry/start.sh &