I just got an Arduino and am trying to turn a servo. The problem is i can't get the servo to turn 90 degrees at once. With the sample code
from
www.arduino.cc (plus some slight modifications) I can still only get my servo to turn about 10 degree steps. Here is my code:
int servo = 9;
int angle;
int pulseWidth;
void servoPulse(int servo, int angle){
pulseWidth = (angle * 35);
digitalWrite(servo,HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(servo,LOW);
delay(20);
}
void setup(){
pinMode(servo,OUTPUT);
Serial.begin(9600);
}
void loop(){
angle = Serial.read();
angle -= 48;
Serial.println(angle);
servoPulse(servo,angle);
delay(1000);
}
I don't see anything wrong in the code, but im new to robotics so if you see anything pleas say something.
thanks in advance