Actually, 6 lines of code.
(not tested, but for educational purposes)
Code: Select all
import RPi.GPIO as GPIO
GPIO.setup(11, GPIO.IN) # depending on what pin you're using for input
if GPIO.input(11) == False: # or True, depending if your circuit is normally-open or normally-closed
os.system("vlc \"my video filename and location.mpg\"") #or whatever video app you're using, and the proper command line command to start your video
# you could do some fun logging here so you can keep track of when it was triggered, or even send yourself an email alert, take a picture with a webcam... the options are endless.
# you'd probably want to do a time.sleep(0.05) or something here so you don't peg your system to the max in this loop... make sure to import time at the top.
The best way to learn programming is to have a task that you want desperately to accomplish. Interacting with the "real world" is a cool motivator to get started, with very tangible results.