#include <Servo.h>
int BUTTON_PIN = 2;
int POTENTIOMETER_PIN = A0;
Servo servo;
int angle = 0;
void setup(){
pinMode(BUTTON_PIN, INPUT_PULLUP);
servo.attach(9);
}
void loop(){
int potentiometerValue = analogRead(POTENTIOMETER_PIN);
bool buttonState = digitalRead(BUTTON_PIN);
angle = map(potentiometerValue, 0 ,1023,0 ,180);
if(buttonState ==LOW) {
servo.write(angle);
delay(15);
}
}