// #include <Servo.h>
// int servopin = 9;
// int servopos;
// Servo myservo;
// void setup() {
// Serial.begin(9600);
// myservo.attach(servopin);
// Serial.println("Enter the Angle for the servo (0 to 180):");
// }
// void loop() {
// // Check if serial data is available
// if (Serial.available() > 0) {
// // Read the input value
// servopos = Serial.parseInt();
// // Constrain the value to be within the valid range for servo angles
// servopos = constrain(servopos, 0, 180);
// // Write the angle to the servo
// myservo.write(servopos);
// // Print confirmation
// Serial.print("Servo angle set to: ");
// Serial.println(servopos);
// // Prompt for the next input
// Serial.println("Enter the Angle for the servo (0 to 180):");
// }
// }
#include <Servo.h>
int servopin=9;
int servopos=0;
Servo myservo;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myservo.attach(servopin);
}
void loop() {
// put your main code here, to run repeatedly:
// Serial.println("What is the Angle of the server");
// while(Serial.available()==0)
// {
// }
// servopos=Serial.parseInt();
myservo.write(servopos);
servopos=servopos+5;
if(servopos==180)
servopos=0;
delay (1000);
}