Skip to content

Instantly share code, notes, and snippets.

@legotheboss
Last active August 6, 2017 20:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save legotheboss/12dec53d4c2257ed38013ee64fda1324 to your computer and use it in GitHub Desktop.
Save legotheboss/12dec53d4c2257ed38013ee64fda1324 to your computer and use it in GitHub Desktop.
Python Script to Read Garage Sensor
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.IN)
while True:
if (GPIO.input(12) == True):
print('Garage Door Closed')
else:
print('Garage Door Open')
sleep(1);
@Jxck-S
Copy link

Jxck-S commented Aug 5, 2017

If using this with the Garage door tutorial from quick pi you need to change input_pin to 12 for it to work then run it using sudo python read_sensor.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment