Adsense by google:

Source Code for Arduino Servo Control

tower-pro-sg90-servo-and-arduino-uno-wiring-cable-tutorial

tower-pro-sg90-servo-and-arduino-uno-wiring-cable-tutorial

Servo is one type of motor controlled by a frequency signal. However, some types of servo have different ways to control it. Because each type of servo have different degrees of movement.

For example, I use a servo Tower Pro SG90 and controlled using the Arduino UNO. Servo Tower Pro SG90 this has the following specifications (or you can read here for more details):

Tiny and lightweight with high output power. Servo can rotate approximately 180 degrees (90 in each direction), and works just like the standard kinds but smaller. You can use any servo code, hardware or library to control these servos. Good for beginners who want to make stuff move without building a motor controller with feedback & gear box, especially since it will fit in small places. It comes with a 3 horns (arms) and hardware.

Tower Pro SG90 Specifications :
Weight: 9 g
Dimension: 22.2 x 11.8 x 31 mm approx.
Stall torque: 1.8 kgf·cm
Operating speed: 0.1 s/60 degree
Operating voltage: 4.8 V (~5V)
Dead band width: 10 μs
Temperature range: 0 °C – 55 °C

 

Tower Pro SG90 Servo characteristic : Position “0” (1.5 ms pulse) is middle, “90” (~2 ms pulse) is all the way to the right, “-90” (~1ms pulse) is all the way to the left.

This is the Arduino Source Code for the Sweep Mode Servo :

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(2); // attaches the servo on pin 2 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}

About authors
We are writers in avrchip.com. We present the articles on programming and arduino. You can get information on how to program the microcontroller and arduino. How do I write a script language for arduino and avr microcontroller. Most of the authors is an embedded systems engineer, software engineer, and electrical engineer. If you have questions about microcontrollers and arduino, please contact us at writer.avrchip@gmail.com.

Comments are closed.