Files
piplayer/code/test/ir_test.py
T
tilman 39d8462eaa s2
2016-12-04 19:32:39 +01:00

28 lines
506 B
Python

import RPi.GPIO as GPIO
import time
# photo sensor on PIN 4
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN)
# LED on PIN 17
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.LOW)
try:
print('Start IR test')
while True:
time.sleep(0.25)
if (GPIO.input(4) == GPIO.LOW):
print('LED OFF')
GPIO.output(17, GPIO.LOW)
else:
print('LED ON')
GPIO.output(17, GPIO.HIGH)
except KeyboardInterrupt:
print('bye')
GPIO.cleanup()