Hello, it's me again. I am now creating a small arm out of things around the house and 2 servo motors. I have a servo motor attached to the bottom of a small circular base with tape. Furthermore, I have a rectangular piece of plastic on the other side opposite of the bottom which sticks up in the air, and I will attach the other motor to the top of this piece at a sideways angle for arm movement.
Everything is cool, and I hooked it up to my joystick and mapped it and everything, it just moves a bit too quickly for my liking, which could tear up the electrical tape keeping the servo for the base movement operational. How can I slow the movement rate of my servo?
I don't know if i'll need to provide my code, I am just putting together what I can for now before my other servos come in the mail. I knew I wanted to make a project like this so I sketched it out and started
Two problems here. To slow down servo movement, you write your code so that it generates successive small steps in the servo commands, giving each step a time to implement.
However, a significant problem may be when the system is switched on each time as the previous servo postilion may not be known and the servo will rapidly move to whatever starting position the code defines.
I see what you mean with the second paragraph, however, that doesn't pose an issue as of yet, and I can fix that up with a when or if statement.
Here is the loop I have
int state = analogRead(joysti);
map(joysti,0,1023,0,255);
servo1.write(state);
I can see that one issue, if I want it to go slower i'll need to do more than just feed the value of the joystick into the servo. There are probably many ways to fix this, none of which I can see, as I'm new and I don't think the delay command would do much other than clutter it up and make it choppy. Do you see any ways to fix this?
The MobaTools servo class also allows speed control.
Be careful not to write values to the servo outside of its range of movement. Not all servos will do the full 180 and some do more. Experimentally determine their range of motion before using them.
How fast do you want the servo to move? I'd think I'd approach it by keeping track of the target position separately than the servo position and moving the servo one count closer to the target each ??? amount of time.
groundFungus has specified the library which I did not recall, but suffice to say, using a loop with a small delay() would perform the needed function without "chop" if there were no other functions needed in addition.
Okay, thanks for the notice. Mine does 180, but only does 360's if I've messed up the code, or is receiving too much information. It occasionally does 360's is my point, and i've tested it. Thanks for the solution.