So I finally got the servo motor in the mail today. I couldn't wait to hook it up. The setup was really simple, the only thing I found odd was that when I started I was able to drive the servo off of pin 13. After a couple of demos I couldn't use pin 13 any more. So I've been using pin 2 to drive the servo now instead. Any ideas about that?
This is my very simple code. I used java to communicate with my COM4 port to test out the servo. It works great so far. I'm currently trying to figure out what the range of this servo is, and I haven't found a datasheet for it yet. I have the TowerPro 9805BB.
So the next step is going to be making this thing wireless I think. I may even just use my laptop now to take commands over the LAN and send that data over com to the arduino. That way I can program up an android app for my tablet.
After that I'm gonna start hooking up more servos. To control all the servos I think I'm gonna buy one of these Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits. Has anybody used this breakout board before? Any suggestions for what gage wire to used for the 6v and signal wires for 20-30ft before I go look it up? Also does anybody know what would be a good 6v power supply. Adafruit sells a 5V 10A power supply but I'd kinda like to supply 6V so I can get the most out of my servos.
#include <Servo.h>
Servo myServo;
int incomingByte = 0;
int nPulseWidth = 1500 ; // 1500, defined in servo.h
void setup()
{
myServo.attach(2);
// the library sets all servos to 1500 ms pulse width by default, this is center for a steering servo
Serial.begin(9600);
Serial.println("Completed setup");
}
void loop()
{
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte>0 && incomingByte<180){
nPulseWidth = (int) (incomingByte/90.0*1000 + 500);
myServo.writeMicroseconds(nPulseWidth);
Serial.print("Sending Servo: ");
Serial.println(nPulseWidth,DEC);
}
}
}
