A button that does something

From Interaction Station Wiki
Jump to: navigation, search

So how about wiring a button input that is able to trigger an output?

We need something like this

Button breadboard.png

and some code to run ( this example is just starting another code )

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import os
import subprocess
# setup pin 23 as an intput
GPIO.add_event_detect(23, GPIO.RISING, bouncetime=800)
while True:
        if GPIO.event_detected(23):
		print 'click' 
		os.popen("python /root/Desktop/anothercode.py")