Servo and led control with button not working.

Hello everyone I'm new to arduino and this will be my first post. I basically am creating an iron man mask that is raising and closing with servos. when it is raised the leds in the eyes should be off and they should come back on once its closed. Here is my current code. Currently the button does nothing. I tested the button with the button example to make sure it was wired properly and it responded so i assume i am wired correctly and that it is a programming error on my part.Here is my current code. any help would be greatly appreciated!

// FACEPLATE PUSHBUTTON CONTROLL by Zabana
// This code moves one servo when a push-button is pressed from 0 to 180
// the code have an antibouncing system to avoid wrong instructions to arduino
// Another servo can be added easily following same pattern, just declare a
// second Servo myservo2; Maybe, depending on servo´s placement for the helmet
// you will need to declare also a new pos2 that is opposite to pos
// the pinout can also be changed easily if user needs to.

#include <Servo.h>

boolean buttonState = LOW;
boolean estado=LOW;
int buttonPin = 2; // the number of the pushbutton pin
int ledPin = 13; // the number of the LED pin
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object

pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input

pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
ledPin=LOW; // we starts with faceplate open and eyes off

myservo.write(pos); // we assume pos=0 as faceplate open, change to 180 before if needed
}

void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

delay (50); // we wait a little to avoid bouncing period in pushing

// Now we check if the pushbutton have been pressed.
// if it is, the buttonState is HIGH and estado is low,
// it mean pushbutton was not pressed till now (we avoid multiple pushing and let the servo moves right)

if (buttonState == HIGH & estado==LOW)
{
if (pos=0)
{
pos=180;
myservo.write(pos);
delay (500); // we wait for servo to lift down faceplate to light on eyes
digitalWrite(ledPin, HIGH);
}
else if (pos=180)
{
pos=0;
myservo.write(pos);
delay (150);
digitalWrite(ledPin, LOW); // Faceplate lift up and eyes light off
}

estado = HIGH; // we change estado, so we will not move servo till it´s not pressed and pressed again
}
else if (buttonState == LOW & estado==HIGH) // We do a "reset" to allow now pushing
{
estado = LOW;
delay (500);
}
}

You wrote "if (pos=0)" when you meant "if (pos==0)" and "if (pos=180)" when you meant "if (pos==180)". It's a common mistake.

int ledPin = 13; // the number of the LED pin

pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
ledPin=LOW; // we starts with faceplate open and eyes off

Changing the value of the pin number has nothing to do with changing the state of the pin at the original number.

That's what the digitalWrite() function was invented for.

You've said nothing about how the switch is actually wired to the Arduino. That is critical to being able to read it properly.

PaulS:

int ledPin = 13; // the number of the LED pin

pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
ledPin=LOW; // we starts with faceplate open and eyes off



Changing the value of the pin number has nothing to do with changing the state of the pin at the original number.

That's what the digitalWrite() function was invented for.

You've said nothing about how the switch is actually wired to the Arduino. That is critical to being able to read it properly.

When you are defining names for pins you should use the 'const' keyword:

const int ledPin = 13;

That would have caused an error when you accidentally tried to change the pin number:

ledPin = 0;  //  Can't do that to a 'const'

So does this work for pushing up the plate?
The suit actually has 2 mechanics - the faceplate pushing up and the jaw pivoting ("opening") out or "down". How would we implement that?
Also, is it possible to make it voice controlled?