I'm trying to turn a servo with my arduino when it receives commands from a serial input, in this case my keyboard. I have already done this with motors and it works fine but when I try with my servo it doesn't move at all. So far I have this written
#include <SoftwareServo.h>
SoftwareServo myservo;
int movemotor;
void setup() {
Serial.begin(9600);
myservo.attach (10);
myservo.write(90);
}
void loop() {
movemotor = Serial.read();
if (movemotor = 111) {
for (int pos = 90; pos >=0; pos--) {
myservo.write(pos);
delay(15);
}
}
else if (movemotor = 99) {
for (int pos = 90; pos <= 180; pos++) {
myservo.write(pos);
delay(15);
}
}
}
I'm powering the servo externally with a 9 volt battery and have made sure to connect its ground to that of the arduino but can't see anything else I did wrong. Any help would be greatly appreciated.