Difference between revisions of "A button that does something"

From Interaction Station Wiki
Jump to navigation Jump to search
(Created page with "So how about wiring a button input that is able to trigger an output? We need something like this File:Button breadboard.png and some code to run ( this example is ju...")
 
Line 35: Line 35:
  
 
</source>
 
</source>
 +
[[Category:Raspberry pi]]

Revision as of 10:21, 21 November 2022

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
GPIO.setmode(GPIO.BCM)

# setup pin 23 as an intput
GPIO.setup(23,GPIO.IN)
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")
		
GPIO.cleanup()