Created
February 10, 2015 20:18
-
-
Save aitzol/1b1642712146adf5bcd8 to your computer and use it in GitHub Desktop.
Python code to check any Raspberry Pi GPIO status
This file contains hidden or 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
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BCM) | |
while True: | |
data = raw_input("Insert GPIO BCN number to check status (blank to quit): ") | |
if data == '': | |
break | |
try: | |
number = int(data) | |
except: | |
continue | |
GPIO.setup(number, GPIO.IN) | |
st = GPIO.input(number) | |
print st | |
Doesnt work. i get an error saying raw_input is not defined
raw_input is a python2 built-in function, python3 has renamed to input. So if you want to use this snipped with python3 you have to change line 7 and use input()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great thx for sharing this :)