Skip to content

Instantly share code, notes, and snippets.

@Jxck-S
Forked from legotheboss/read_sensor.py
Last active August 6, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jxck-S/c4a627a45bf00fa4047481d288fb7c5e to your computer and use it in GitHub Desktop.
Save Jxck-S/c4a627a45bf00fa4047481d288fb7c5e 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('\x1b[1;37;42m' + 'Garage Door Closed' + '\x1b[0m')
else:
print('\x1b[1;37;43m' + 'Garage Door Open' + '\x1b[0m')
sleep(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment