Button and led problem

Hi, I’ve been working on a project this afternoon. What is does is when you push the button, it changes the led, and there are 4 leds. You toggle through them each time you push the led. The problem is that even though I push the button, it doesn’t toggle. Any help would be highly appreciated.

This device is used for the testing of the solar car. It is to be used for
indoor testing. It is attached to the motor and spins at 4 different speeds,
5 volts which is the power of the arduino, 2 volts which is the maximum power harnessed by the solar panel, 0 volts, and analog provided by a pot.
Toggle from each mode by pushing the button and a led will indicate the mode:
Red: 5 volts
Green: 2 volts
Yellow: 0 volts
Blue: pot
//Set up button 
int buttonPin = 2;
int buttonState = 0;
//Set up motor
int motorPin = 9;
//Set up pot
int potVal;
float potVolts;
//Set up led pins
int ledPins[] = {3,4,5,6};
//Set up toggle var
int toggleNum = 0;
void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:


void setUpPins(){
  pinMode(buttonPin, INPUT);
  pinMode(motorPin, OUTPUT);
  for (int i=0; i<=3; i++){
  pinMode(ledPins[i], OUTPUT);

void buttonPress(){
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {

void getPotVoltage(){
  potVal = analogRead(A0);
  // Convert the analog reading (w
  potVolts = potVal * (5.0 / 1023.0);

void ledToggle(){
     toggleNum = 0;

void mode1(){
  digitalWrite(ledPins[0], HIGH);

void mode2(){
  digitalWrite(ledPins[1], HIGH);

void mode3(){
  digitalWrite(ledPins[2], HIGH);

void mode4(){
  digitalWrite(ledPins[3], HIGH);

void stopLeds(){
  for (int i = 0; i<=3; i++){
    digitalWrite(ledPins[i], LOW);

Sorry about the bad programming. I was into Java Script for a few months so I haven't done arduino for a while.

Did you do any testing before you reached this stage? Do you have any simpler sketch that does something simpler in order to test the hardware?

The way to troubleshoot is "divide and conquer".

void loop() {
  // put your main code here, to run repeatedly:     <<<<<<<<<<<<<<<


I'm so stupid!

But now when I press it, All leds are turning on and won't turn off.

you need to post your new code

I have solved it by putting a "lock" on the button. Thanks for all your help and support.