Actually, we previously published Servo Motor Arduino Code for the Beginners but after publishing the guide Best Servo Motor for the Beginners we thought to somewhat rewrite the old guide with this new title Tower Pro SG 5010 Servo Motor Test Code for Arduino with proper sketch and video demo. You can read the former guide later after reading guide.
Tower Pro SG 5010 Servo Motor Test Code for Arduino
We already pointed on how to build a DIY robotic arm. We can fine tune the degrees of sweep, time to be taken and step by degree. We kept the below code in Github as Gist too as well as the whole stuff as Firtzing Project (recommended to check) :
// coded by Dr. Abhishek Ghosh @AbhishekCTRL
int pos = 0;
for(pos = 0; pos < 180; pos += 1) // 0 to 180 degrees with 1 degree step
delay(120); // time set 120 ms to reach sloooooowly
#include – that is Arduino specific. If you are advanced user you may read how to code in C for Arduino.
towerprosg5010 – need not to be explained, it is just a phrase, we could use
towerprosg5010.attach(9) – we attached the servo motor pin 9. You can change it.
for(pos = 0; pos < 180; pos += 1) - we are telling to sweep 0 to 180 degrees with 1 degree step
delay(120) - if you lower it, the sweep will be faster.
The circuit is very easy. The servo motor will have the end with 3 holes which can easily accommodate the pin of a jumper wire. For this code, yellow will get connected to the pin 9 on Arduino UNO board, Brown will go to ground/GND and the red will go the 5v pin of Arduino board. This is becoming our kind infographics cum circuit diagram :
Video Demo of Tower Pro SG 5010 Servo Motor Test Code for Arduino
Definitely, we have a crap quality video! Crap quality is good because it will save the bandwidth and serve the purpose :
Follow the Author of this article :