Help me with this push button problem

Hey guys, so basically im doing this simple thing with the Arduino Uno, push button and 1 servo motor, the problem is that i just bought this push button and it isn’t working properly. For example, when i pressed the button it doesn’t do anything except when i push the button itself into the pins.

Here is my code:

  • #include <Servo.h>;
  • const int buttonPin = 12;
  • Servo servoMotor;
  • const int LED = 13;
  • int buttonState = 0;
  • void setup(){
  • Serial.begin(9600);
  • pinMode(buttonPin,INPUT_PULLUP);
  • pinMode (LED,OUTPUT);
  • servoMotor.attach(2);
  • servoMotor.write(0);
  • }
  • void loop()
  • {
  • buttonState = digitalRead(buttonPin);
  • if(buttonState == HIGH) {
  • servoMotor.write(125);
  • digitalWrite(LED,HIGH);
  • delay(25);
  • }
  • else{
  • servoMotor.write(0);
  • digitalWrite(LED,LOW);
  • delay(25);
  • }
  • }

I see the problem, but I'm not going to give you the answer until you put your code inside Code brackets and format it correctly :roll_eyes:

After editing your post to add code tags, tell us how you wired the pushbutton.

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:

Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]