from machine import Pin,PWM,ADC
from time import sleep
import hcsr04
Ultra1 = hcsr04.HCSR04(21,18)
Ultra2 = hcsr04.HCSR04(14,25)
servo1=PWM(Pin(19),freq=50)
duty_cycle=0
servo2=PWM(Pin(2),freq=50)
duty_cycle=0
led1 = Pin(5, Pin.OUT)
led2 = Pin(4, Pin.OUT)
while True:
ourDistance1 = Ultra1.distance_cm()
print("Mera distance hai1: ",ourDistance1)
ourDistance2 = Ultra2.distance_cm()
print("Mera distance hai2: ",ourDistance2)
if ourDistance1 <= 100:
print("Gate1 and 2 Closed")
LED1.value(1)
LED2.value(1)
Servo(myServo, 180)
if ourDistance2 <= 100:
flag = True