3
0

Added LED part for IR sensor code (assignment 3)

This commit is contained in:
K 2024-10-23 13:34:18 +05:30
parent 828a3710b0
commit adf042c212
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -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