From adf042c2129e550dfffa74d2bfe4c6b1bcc87252 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Wed, 23 Oct 2024 13:34:18 +0530 Subject: [PATCH] Added LED part for IR sensor code (assignment 3) --- Practical/Assignment-3/IoT - Code-3.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Practical/Assignment-3/IoT - Code-3.py b/Practical/Assignment-3/IoT - Code-3.py index 761f022..1404495 100755 --- a/Practical/Assignment-3/IoT - Code-3.py +++ b/Practical/Assignment-3/IoT - Code-3.py @@ -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