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.setwarnings(False)
|
||||
GPIO.cleanup()
|
||||
GPIO.setup(16,GPIO.IN)
|
||||
GPIO.setup(16,GPIO.IN) # For IR sensor
|
||||
GPIO.setup(26,GPIO.OUT) # For LED
|
||||
|
||||
try:
|
||||
while True:
|
||||
if (GPIO.input(16)):
|
||||
print("No object")
|
||||
GPIO.output(26,GPIO.LOW) # LED OFF when no object detected
|
||||
else:
|
||||
print("Object Detected")
|
||||
GPIO.output(26,GPIO.HIGH) # LED ON when object detected
|
||||
except KeyboardInterrupt:
|
||||
GPIO.cleanup()
|
||||
# END OF CODE
|
||||
|
Loading…
Reference in New Issue
Block a user