import time
from machine import PWM, ADC, Pin, RTC
print("Hello WOrld")
rtc= RTC()
rtc.datetime((2024,4,10,15,10,40,0,0))
print(rtc.datetime())
# print(time.tick_us())
motor = PWM(Pin(0))
motor.freq(50)
verticle = ADC(26)
horizontal = ADC(27)
select = Pin(28,Pin.IN,Pin.PULL_DOWN)
position = 4750
value = False
while True:
if select.value()==1:
print("Clicked")
if position==4750 and value:
t = rtc.datetime()
h = str(t[-4])
m = str(t[-3])
s = str(t[-2])
print(f"Gate Closed at {h}:{m}:{s}")
value=False
while verticle.read_u16()<32759 and position<4750:
position+=1
motor.duty_u16(position)
value = True
while verticle.read_u16()>32759 and position>1001:
position-=1
motor.duty_u16(position)
print(verticle.read_u16(),position)
time.sleep(1)