Hi Here,
this is my first post. I try to find an issue alone, checking online but without success
I am making my first arduino project and got a problem
I guess it is a very simple code but i should make something wrong because it doesn't work
i got a servomotor and want to generate a pendulum mouvement with it.
For a reason i don't understand, the servo makes a rest at the end of the cycle...
It goes... and comes ...and wait before going again
Anyone sees what's wrong ???
Any feedback appreciated !
thx
#include <Servo.h>
Servo myservo;
int pos;
int angleInit;
int angleMax;
int angleMin;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
angleInit = 12;
myservo.write(angleInit);
delay(1000);
angleMax = angleInit+3;
angleMin = angleMax-6;
myservo.write(angleMax);
}
void loop()
{
for(pos = angleMin; pos < angleMax; pos += 1)
myservo.write(pos);
delay(100);
}
for(pos = angleMax; pos > angleMin; pos -= 1)
{
myservo.write(pos);
delay(100);
}
}