From 5c45b27fec90547a84067ff5c3de407f9b629090 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Thu, 17 Oct 2024 19:11:52 +0530 Subject: [PATCH] Added code for IR sensor, i.e. assignment 3. --- Practical/Assignment-3/IoT - Code-3.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 Practical/Assignment-3/IoT - Code-3.py diff --git a/Practical/Assignment-3/IoT - Code-3.py b/Practical/Assignment-3/IoT - Code-3.py new file mode 100755 index 0000000..761f022 --- /dev/null +++ b/Practical/Assignment-3/IoT - Code-3.py @@ -0,0 +1,26 @@ +""" +THIS CODE HAS BEEN TESTED ON RASPBERRY PI 3B and 4B AND IS FULLY OPERATIONAL. + +Problem Statement: IR Sensor + +Code from InternetOfThingsAndEmbeddedSystems (SPPU - Third Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-te-comp-content/InternetOfThingsAndEmbeddedSystems +""" + +# BEGINNING OF CODE +import RPi.GPIO as GPIO +import time + +GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) +GPIO.cleanup() +GPIO.setup(16,GPIO.IN) + +try: + while True: + if (GPIO.input(16)): + print("No object") + else: + print("Object Detected") +except KeyboardInterrupt: + GPIO.cleanup() +# END OF CODE