I'm working on a project which involves feeding input into several servo engines via button inputs. Today I ran into a problem:
I've broken down the code to the bare minimum to get the servo to do anything at all but that didn't seem to help either. Right now I have the servo hooked up to an Arduino UNO with just one simple button on a breadboard. I'm trying to get the servo engine to move to a specific angle when pushing the button and move back to its idle angle when releasing the button, but it doesn't work with the MC1811. Attempted it with an SG90 servo engine with the same code and it worked.
Now when I load the sweep example from the library (2 for loops that have it go back and forth betwee 0 and 180 degrees) it works for both servo engines. I've tested the button over serial print and it's definitely sending on/off signals.
Any idea what I'm doing wrong? Might be something really obvious; here's the code
#include <Servo.h>
int button = 8;
Servo servo;
void setup() {
Serial.begin(9600);
pinMode(button, INPUT_PULLUP);
servo.attach(3);
}
void loop() {
if (digitalRead(button)) {
Serial.println("on");
servo.write(90);
} else {
Serial.println("off");
servo.write(0);
}
delay(500);
}