Starting a program when button is pressed
Posted: Wed Feb 18, 2015 11:53 am
Hello, i want my raspberry to run deluged when i press a button.
This is my code:
The button works, when i press it the print functions are called, but it doesn't start deluged.
What am i doing wrong?
Thank you
Edit: i'm trying to start deluged with a script
and calling it with call(["/home/pi/myscript.sh"],shell = True)
but it doesn't work
This is my code:
Code: Select all
import RPi.GPIO as GPIO
import time
from subprocess import call
GPIO.setmode(GPIO.BCM)
GPIO.setup(16,GPIO.IN,pull_up_down=GPIO.PUD_UP)
flag = False
while True:
input = GPIO.input(16)
if(input == False):
if(flag == False):
print "calling deluged"
call(["deluged"])
flag = True
time.sleep(0.2)
else:
print "killing deluged"
call(["pkill","deluged"])
flag = False
time.sleep(0.2)
What am i doing wrong?
Thank you

Edit: i'm trying to start deluged with a script
Code: Select all
#!/bin/bash
deluged
but it doesn't work