Hi all, newbie here:
Hope I'm doing this right. I attached a piece of code that I'm having some trouble with.
Problem 1: When first uploaded the servo motor goes to the 90 degree position, I don't understand why that is happening.
Problem 2: When I enter an angle in the Serial monitor the servo goes to that position but then returns to 0 angle after the delay, How do I make it hold it's position?
thanks for any help
#include<Servo.h>
Servo servo;
int servoPin = 9;
void setup() {
servo.attach(servoPin);
Serial.begin(9600);
Serial.print("Enter degrees of rotation:");
}
void loop() {
if(Serial.available())
{
int reading = Serial.parseInt();
servo.write(reading);
delay(1000);
}
}