#include <Servo.h>
Servo myServo;
// Define the pin for the potentiometer
const int potPin = A0; // Connect the potentiometer to analog pin A0
void setup() {
Serial.begin(9600); // Initialize serial communication
myServo.attach(9);
}
void loop() {
// Read the analog value from the potentiometer
int potValue = analogRead(potPin);
int potValue_Mapped = map(potValue,0,1023,0,180);
// Print the potentiometer value to the Serial Monitor
Serial.print("Potentiometer Value: ");
Serial.println(potValue_Mapped);
myServo.write(potValue_Mapped);
delay(100); // Optional delay for readability
}