arduino_servo.png (17522Bytes)
arduino_servo_a_or_b.png (18126Bytes)
It is working now, thanks to everyone who helped me out!!!
I am trying to make my servo work,but if I start my arduino, with code and servo attached, it just goes to one position and stays there twitching. Can someone help me?
second try
I changed the delay to two seconds, but the servo only goes to the first 100 degree and does not move after that unless if I turn the servo. Could it be the servo? I use:http://www.dealextreme.com/p/sg90-mini-servo-with-gears-and-parts-2kg-torque-35764
Code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
myservo.write(0); // sets the servo position according to the scaled value
delay(2000);
myservo.write(100); // sets the servo position according to the scaled value
delay(2000); // waits for the servo to get there
myservo.write(0); // sets the servo position according to the scaled value
delay(2000);
myservo.write(100); // sets the servo position according to the scaled value
delay(2000); // waits for the servo to get there
}
First try
I used a part of the knob controlled servo example.
Code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
myservo.write(0); // sets the servo position according to the scaled value
delay(20);
myservo.write(100); // sets the servo position according to the scaled value
delay(20); // waits for the servo to get there
myservo.write(0); // sets the servo position according to the scaled value
delay(20);
}