My goal is to have a little switch that when closed runs a bash command (vlc stream over http) and when open stops that command.
Code: Select all
import RPi.GPIO as GPIO
import time
import os
def start():
print('start')
os.system("/home/pi/scripts/mp3stream")
def stop():
print('stop')
os.system("/home/pi/scripts/stopstream")
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
if GPIO.input(16) == GPIO.HIGH:
while GPIO.input(16) == GPIO.HIGH:
time.sleep(0.1)
start()
elif GPIO.input(16) == GPIO.LOW:
while GPIO.input(16) == GPIO.LOW:
time.sleep(0.1)
stop()Code: Select all
pkill vlcI'm more than happy to hear any advice, thanks for your time