# Project objective: Gradually move the servo arm to its min to max position (at 100 increaments) and vice-versa
#
# Hardware and connections used:
# Servo GND to Raspberry Pi Pico GND
# Servo V+ to Raspberry Pi Pico 3.3 V
# Servo PWM pin to GPIO Pin 15
#
# Programmer: Adrian Josele G. Quional
# modules
from picozero import Servo # importing Servo class to easily control the servo motor
from machine import ADC,Pin
from time import sleep
sleep(0.5)
# creating a Servo object
servo = Servo(15)
# creating a Potentiometer
pot = ADC(27)
x = 0
# continuously and gradually move the servo arm from min to max position (and vice-versa) at 100 increments (for a duration of 0.01 sec each increment
while True:
pot_value = pot.read_u16()
volt = round((3.3/65535)*pot_value,2)
percent = int(pot_value/65535*100)
print (percent"\n ")
x = input()
servo.value = x /100
sleep(1)