I'm trying to make sketch that will let me control a servo I have (Futaba S148) via serial. The code I have thus far is as follows:
Code: Select all
#include <ServoTimer1.h>
ServoTimer1 servo1;
int var;
void setup() {
Serial.begin(9600);
servo1.attach(10);
}
void loop() {
if (Serial.available()) {
var = Serial.read();
Serial.println(var);
Serial.println(var, BYTE);
servo1.write(var);
}
}
I put in the Serial.println() parts to try and debug why the sketch wasn't working and when I type in an ange such as 155 the servo does not move and I receive this
from the serial monitor. So I am assuming that it is taking each part of what I put in (155) and breaking it up into separate parts. Is there a way to fix this? Also, the basic ServoTimer1 code works fine and the servo sweeps back and forth. Let me know if you need any additional information.