Push button not returning a 1/Low when released

I am trying to write reaction time code. Right now I am simply trying to test the values for the press button. When I press the button I get a value of 1 but it stays at 1 once I release the button. What am I doing wrong?

const int ledPinA = 14;
const int ledPinB = 19;
const int ButtonA = 7;
const int ButtonB = 11;
elapsedMillis Timer;

void setup()
pinMode(ledPinA, OUTPUT); //initiates the light for light A
pinMode(ledPinB, OUTPUT); //initiates the light for light B
pinMode(ButtonA, INPUT);
pinMode(ButtonB, INPUT);
Serial.begin(38400); //initiates the Serial
while (!Serial){


int val;
int result;

void loop()


What am I doing wrong?

Not using a pulldown resistor on the input so that it is a known state when the button is not pressed ?

This tells you why:

Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.