Hi.
I am trying to control some servos. I have a pushbutton to activate a sequence where my servos move according to the code.
When the sequence is finished they detach.
When i upload my program the servos rush to their centre and then to my initial position. I have tried to first attach the servos when i push the button, but the first time after i power on the board the servos will go to their centre position no matter what...
The funny thing is, if i detach the servos in my sequence and then start the sequence again, with attaching the servos, they don't go to their centre... it is only the first time after a powerup og download of the program...
Because that's how the servos are programmed? They go to centre by default on powerup. After receiving pulses on the control line they will go to that position (and hold there if pulses stop).
I think the servo library contains the default center position (as well as the default min and max positions) for the servo on startup. A solution may be to set the desired servo start position in the setup portion of the code.
If i power up a servo it does not move at all, except for when i am giving it a pulse...
But in this case they have power all the time.. the only thing that is happening is that i power up the arduino. The servos stay powered...
If i do the positioning in the setup, the servos do exactly the same.. they rush to centre and back to the positions i set them to...
If i set the pushbutton to attach the servos i can power the arduino up without anything moving. When i push the button, they go to the centre again and then to the desired position. As i mentioned they don't do that if i detach and attach again while the arduino is running. Only the first time i attach..