I have a sketch set up to run switch case statement base on voltage of a potentiometer. I have it set so case 0 has an if statement to light up LED's if the button is pressed. For some reason the LED flicker on every 6 seconds or so and then turn back off even when nothing is attached to A5(the pin going to the button). If I change the potentiometer to the highest voltage the LEDS don't light up. I am not sure how it is getting an analog reading even when no cable is plugged into the A5 pin. Also, when the LEDs are off I can push the button and they turn on, as soon as I let got they turn off again. This is very odd, any ideas?

It is supposed to only light the LEDs when I push the button. How ever the LEDS light up even when there is nothing on the A5 pin. I can literally remove the cable from the arduino and it still lights the LEDs up randomly. I have changed the A5 from INPUT to INTPUT_PULLUP but then nothing happens. Wont light up period

"tutorial on pull up resistors" Huh? Just enable them to hold the pin at a steady HIGH when not grounded.

I think it works because this int buttonstate = analogRead(buttonApin);returns a value of 0-1023, and you were checking for buttonstate == LOW,which doesn't really make sense.digitalRead looks for HIGH, LOW, so that makes more sense.