#include <Servo.h>
Servo servoMotor1; // Create a servo object to control the servo motor
int servoPin = 9; // Define the pin to which the servo is connected
int potPin = A0; // Define which port is receiving signal from potentiometer
void setup() {
servoMotor1.attach(servoPin); // Attach the servo to the specified pin
}
void loop() {
int reading = analogRead(potPin); // Read value of potentiometer from analog input pin A0
int angle = map(reading, 0, 1023, 0, 180); // Convert voltage level readings to an angle
servoMotor1.write(angle); // Send command to servo
}