Created
August 8, 2020 18:10
-
-
Save emilyvelasco/d0ea746efcc77bd006ee4781b9d9dffc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import sys | |
import os | |
from subprocess import Popen | |
import time | |
import random | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) | |
movie1 = ("/home/pi/Videos/video1.mp4") | |
movie2 = ("/home/pi/Videos/video2.mp4") | |
movie3 = ("/home/pi/Videos/video3.mp4") | |
movie4 = ("/home/pi/Videos/video4.mp4") | |
movie4 = ("/home/pi/Videos/video5.mp4") | |
last_state1 = False | |
input_state1 = False | |
player = False | |
movie_list = [movie1, movie2, movie3, movie4, movie5] | |
randomvideo = random.choice(movie_list) | |
while True: | |
#Read states of inputs | |
input_state1 = GPIO.input(17) | |
print input_state1 | |
#If GPIO(17) is shorted to ground | |
if input_state1 != last_state1: | |
if player: | |
os.system('killall omxplayer.bin') | |
if input_state1: | |
omxc = Popen(['omxplayer', '-b', '--win','0 50 690 480', randomvideo]) | |
player = True | |
time.sleep(98) | |
#Set last_input states | |
last_state1 = input_state1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment