#Articulated arm - potentiometer control of servos
from machine import Pin,ADC,PWM
from time import sleep
#Configure the servo pins for PWM output
servo1=PWM(Pin(0))
servo2=PWM(Pin(1))
servo3=PWM(Pin(5))
servo1.freq(50)
servo2.freq(50)
servo3.freq(50)
#Configure the potentiometer pins for ADC input
potentiometer1=ADC(Pin(26))
potentiometer2=ADC(Pin(27))
potentiometer3=ADC(Pin(28))
while True:
#these lines set the duty cycle to a value between 3000 & 7000
#which corresponds to a pulse width of 1ms to 2ms
servo1.duty_u16(int(3000+potentiometer1.read_u16()*4000/65536))
servo2.duty_u16(int(3000+potentiometer2.read_u16()*4000/65536))
servo3.duty_u16(int(3000+potentiometer3.read_u16()*4000/65536))
sleep(0.1)