Cool, glad it worked for you. If you need to speed it up you could send the servo index and position as bytes rather than ASCII and skip the “p/m/g” separators, they are only that way as per the original SingleServoExample to make it easy to test interactively from the serial terminal.
I had been search better solutions for servo control for Arduino. I have been modified the SAMPLE from arduino but my quadbot seems like got STROKE attack. It just not working right. I am gonna try this tonight and thanks again!
You’re welcome. One thing I found when using lots of servos is that they drain a lot of current when they’re all working at once, and if your power supply and/or battery isn’t up to it and the supply voltage on the servos sags too much the controllers in the servos will go crazy or stop working, then the voltage goes up with no load and they start working again, etc. So it will look like it’s your software that’s messing up, but really it’s the hardware.
This is a tiny “interpreter” that lets you send decimal numbers through the serial port. Every time it gets a new digit it multiplies the previous value by 10 and adds the value of the new digit.
The (ch-‘0’) part subtracts the ASCII value for zero from the digit so that ‘0’ will be converted to integer 0 and ‘9’ will be integer 9, and so on.
For example, when it receives the character sequence ‘1’ ‘2’ it will end up with (1*10 + 2 = 12) in the pin number.