Added LED part for IR sensor code (assignment 3)
This commit is contained in:
parent
828a3710b0
commit
adf042c212
@ -13,14 +13,17 @@ import time
|
|||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
GPIO.setup(16,GPIO.IN)
|
GPIO.setup(16,GPIO.IN) # For IR sensor
|
||||||
|
GPIO.setup(26,GPIO.OUT) # For LED
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
if (GPIO.input(16)):
|
if (GPIO.input(16)):
|
||||||
print("No object")
|
print("No object")
|
||||||
|
GPIO.output(26,GPIO.LOW) # LED OFF when no object detected
|
||||||
else:
|
else:
|
||||||
print("Object Detected")
|
print("Object Detected")
|
||||||
|
GPIO.output(26,GPIO.HIGH) # LED ON when object detected
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
# END OF CODE
|
# END OF CODE
|
||||||
|
Loading…
Reference in New Issue
Block a user