kenwood120s:
You're closing loop() prematurely with this } marked XXX below:void loop() {
while(HIGH == digitalRead(10));
myservo.write(0); // Set Servo 1 to 0 degrees
} //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
while(LOW == digitalRead(10));
Thank you, this fixed the code, I had one } too many ![]()
But removing the delay hasn't changed the speed the servo is moving at. Is it possible that the servo just can't do it faster?
New code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
pinMode(10, INPUT_PULLUP);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
while(LOW == digitalRead(10));
myservo.write(0); // Set Servo 1 to 0 degrees
while(HIGH == digitalRead(10));
myservo.write(110); // Set Servo 1 to 0 degrees
}