print("Hello, ESP32!")
from machine import Pin,PWM,ADC
import time
pot=ADC(Pin(34))
sg90 = PWM(Pin(22, mode=Pin.OUT))
sg90.freq(50)

# 0.5ms/20ms = 0.025 = 2.5% duty cycle
# 2.4ms/20ms = 0.12 = 12% duty cycle

# 0.025*1024=25.6
# 0.12*1024=122.88
pot.atten(ADC.ATTN_11DB)
while True:
    v=(int(pot.read()+180)%180)
    print(v)
    sg90.duty(v)
    time.sleep(1)