#Code Author-> Ananta Mondal, B.Tech EE 3rd Year Roll-10901621030
#Assisted & small bugs fixed by-> Sayan Mondal, B.Tech EE 3rd Year Roll-10901621013
#Date of writing the code: 25/08/2023 at NSEC
from machine import Pin
from hcsr04 import HCSR04
from time import sleep
# Initialization of Sensors:
sensor1 = HCSR04(trigger_pin=0, echo_pin=1, echo_timeout_us=1000000)
# Initialization of LEDs:
ledy1 = Pin(4, Pin.OUT)
ledr1 = Pin(5, Pin.OUT)
ledg1 = Pin(6, Pin.OUT)
print("fuck")
# Infinite loop to keep the system running:
while True:
#Main logic block:
if distance1 <= 40 or distance1 >= 10
ledy1.value(1)
print("led1")
elif distance2 <= 100 and distance1 > 400:
ledg1.value(1)
print("led2")
else:
ledr1.value(1)
print("led3")
sleep(0.5)
#fetching of distance in cm via distance_cm() function and initializing distance variables as per:
distance1 = sensor1.distance_cm()
#Resetting of all LEDs to OFF state:
ledr1.value(0)
ledg1.value(0)
ledy1.value(0)