from machine import Pin,PWM,ADC
from time import sleep
def led(x):
led.value(not led.value())
led=Pin(23,Pin.OUT)
servoh=PWM(Pin(22), freq=50)
servov=PWM(Pin(5),freq=50)
sel=Pin(16,Pin.IN,Pin.PULL_UP)
vert=ADC(Pin(15))
hor=ADC(Pin(2))
vert.width(ADC.WIDTH_9BIT)
vert.atten(ADC.ATTN_11DB)
hor.width(ADC.WIDTH_9BIT)
hor.atten(ADC.ATTN_11DB)
sel.irq(trigger=Pin.IRQ_FALLING,handler=led)
led.value(0)
while(1):
datov=vert.read()
datoh=hor.read()
datoh=511-datoh
datov=511-datov
datov=(datov*100/511)+25
datoh=(datoh*100/511)+25
servoh.duty(int(datoh))
servov.duty(int(datov))
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4