Can't control Modelcraft MC1811 micro servo

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);
}

I'm not surprised that nothing happens as both of your servo.write() statements tell it to go to the same place.

Have you tried the servo sweep example that comes with the Arduino IDE?

...R

Oh that was just my mistake trying to make the code prettier before posting it, I've actually been trying it with 0 and 90 degrees (gonna edit the code above) to no avail. Also yep, tried it and it worked. Basically I can control the servo in intervals through for-loops but can't tell it to go to a position directly via write()

I suspect a problem with your button. Try a pot instead, and move the servo according to the wiper position.

dingus123:
Oh that was just my mistake trying to make the code prettier before posting it,

Well post a program that does not have mistakes and which demonstrates the behaviour you have a problem with. Make sure that you post a program that you have actually tried on your Arduino.

...R

Hi,
How have you got your button wired?
What sort of button is it? (picture please)
You have PULL_UP turned ON, so your button must go from pin 8 to gnd.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: