Skip to content

Instantly share code, notes, and snippets.

@basuke
Created April 28, 2013 04:44
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 basuke/5475916 to your computer and use it in GitHub Desktop.
Save basuke/5475916 to your computer and use it in GitHub Desktop.
Raspberry Pi Kitchen Range Monitor using GPIO
from time import sleep
import RPi.GPIO as GPIO
from sys import exit
GPIO.setmode(GPIO.BCM)
pins = [18,23,24,25]
[GPIO.setup(pin, GPIO.IN) for pin in pins]
print "Ready."
while True:
try:
states = [GPIO.input(pin) for pin in pins]
#print states
print " ".join("ON " if state else "OFF" for state in states)
sleep(1)
except KeyboardInterrupt:
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment