Servo twitching. I know, simple stuff, but it's interesting to play with on new hardware. Another Arduino example "sketch" (they got a number of these) called Sweep simply moves a servo through a set range, back and forth. Just looking at the sketch (listed at bottom) this timeshows a servo controlsignla connected to pin 9. They recommend using the boards 5 volts to power the servo, which is coming from the USB connection. If I'd had a bigger servo, or was under load, it might be appraoching the 500 mA USB limit (or is it more now?). ANyway, here's the servo, and the seperation of the yellow signal wire from the power wires.
All that is required is to pry the little bit of plastic up that is holding the metal pin in the housing, letting it slip out.
The +5 and ground pins are by each other on the bottom of the board, and pin9 is up top, and is a PWM pin, I wonder why? : ) So it's just plug everything in, load up the sketch and off we go. Intersting thing, the flashing LED code was still in, running, and apparently something was going on with pin 9 since the servo was twitching ever now and then. Little glitch, just something to keep in mind. Below is the connections, and even further below, a little video of it moving. Aww, ain't that cute. Fun stuff!
// Sweep
// by BARRAGAN <http://barraganstudio.com>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 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
}
}
https://www.youtube.com/watch?v=wGnMHKFXGU8