I have a problem here that I've been all day long trying to figure out, and its driving me crazy!
I want to use a NPN transistor as an On/Off switch for a servo. (why? because i made the servo continuous, and the servo still rotates on the "center angle", tho im experimenting this with a regular servo)
That's a low-gain transistor.
The value of that base resistor is very high, so the base current is very low.
Consequently the collector current you can expect is marginal at best.
Try something much lower, 200?.
Does it still try to move if you stop sending it pulses? You may be able to use an if statement to create a dead zone around 0 / center that doesn't send anything.
(why? because i made the servo continuous, and the servo still rotates on the "center angle", tho im experimenting this with a regular servo)
Use writeMicroseconds position commands for finest control. If needed, the servo can be detached/attached to possibly fix pot drift issues.
// zoomkat 10-14-11 serial servo test
// type servo position 500 to 2500 in serial monitor
// type in number <500 to detach servo
// for IDE 0022 and later
// Powering a servo from the arduino usually DOES NOT WORK.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7); //the pin for the servo control
Serial.println("servo-test-22"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); // allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
int n = readString.toInt();
if (n < 500) {
myservo.detach();
}
else {
myservo.attach(7);
myservo.writeMicroseconds(n); //convert readString to number for servo
}
readString=""; //empty for next input
}
}