Not all statements in else if function running

Hey guys,

I'm writing a code to programme a game on a joystick potentiometer. When a button is pressed, one of four LEDs randomly lights up. The player must then press the joystick in the given direction. If they get it right, they get "Well done!". If they don't press the button quick enough, they get "Too slow". If they get it wrong, they get "Incorrect".

I'm having an issue with my "Incorrect" statement though. Here's the code for the UP direction:

Check your syntax.


Don’t use pin #1, it and pin 0 are used for communications.

Those have to be separate comparisons. Like so:

potInput1 > 450 && potInput1 < 650

The original evaluates to either 0 < 650 or 1 < 650 both of which are true.

Perfect, that solved it, thank you!

I've changed my pin1 to pin6 but my push button to start is still ignored; is there something else off in my code for that?

The part in question:

Please do not post snippets.

How is the switch (pushbutton) wired? Is there a pull down resistor?

Apologies.

I have a simple push button, connected to pin 6 and ground. The code ignores it completely, that is, regardless of whether the button is pressed, it runs continuously.

Unless you have an external pullup resistor on that pin, set the pinMode to INPUT_PULLUP.

The switch input will read HIGH when the button is not pressed and LOW when pressed if the switch is wired to ground and an input set to INPUT_PULLUP.

Perfect, by switching to LOW and INPUT_PULLUP my button issue was fixed, thank you so much!