Momentary Push Button and LED

Greetings All,

I have built a program that I want to use to turn on an LED with a momentary push button. What I want it to do is, I want the LED to come on and stay on when I push the button and then I want it to turn off and stay off when I push the button again. Since the push button is momentary, it is a little more complicated than I expected. I thought I had the program down with the one I have provided below, but the LED blinks over and over and the push button does not do anything at all. What do you recommend I do to fix this?

My Program:

//Constants
const int yellowledPin = 32; //LED Pin
const int singlePin = 38; //Push Button

boolean on=false; //For Button Switch

//Changing
int singleState = 0;

void setup() {
pinMode(yellowledPin, OUTPUT);

pinMode(singlePin, INPUT);
}
void loop() {
//adjustercheck:
singleState = digitalRead(singlePin);
if(singleState == HIGH) {
  if(on == true) {
    on = false; 
  }
  else {
    on = true;
  }
}

  if (on == true) {
    digitalWrite(yellowledPin, HIGH);
  }
  else {
    digitalWrite(yellowledPin, LOW);
  }
  delay(500);
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

(deleted)

How fast does the led blink? Maybe you did not upload and the previous sketch that you loaded was blink?

Are you using a pull-down or pull-up resistor for button?

Do you have the correct pin configured in the code?

Do you have a blinking led ? (Some blink by themselves automagically when powered)

Ensure the button is wired properly: here it needs an external pull down and of course ensure you wired two diagonally opposed pins of the button (most have 4 legs, connected 2 x 2)

Ensure you have a Resistor for your led.

The delay 500 will kill your user experience - get rid of it (or keep a delay(15) if you want the poor’s man debounce).