Serial monitor false reading of input button

Hi there!

I am trying to incorporate a snooze button for an alarm clock I am building.
More info about that project here: Help with fading lights and music for alarm clock

I am having the problem that my Arduino seems to read a false input from my input button. (see this screen shot. I am not doing anything at this moment. And the SnoozePin gives back a 1...

I am using a standard press button that I connected to ground thourgh a 10K resistor, like this.
button schematic

When I measure the hardware with a multimeter the button seems to work fine. Therefore I think that I screwed up in my coding.


int SnoozePin = 8;
int Snooze_pressed;

void setup() {
  pinMode(SnoozePin, INPUT);
  Serial.begin(9600);
}

void loop() {
  Snooze_pressed = digitalRead(SnoozePin);
  Serial.print("Snooze:"); Serial.println(Snooze_pressed);
  //  Snooze_pressed == false;
  delay(100); // Bounce button
}

Does anybody know what I did wrong?
Thanks in advance!

For switch connections to the Arduino.

Maybe not.

What is the 10k resistor for?

Why didn't you use the built-in pullup resistors?

1 Like

It was a floating pin... @TheMemberFormerlyKnownAsAWOL The pullup resistor comment made me google it and I found a very nice youtube tutorial explaining it.

Thanks for the help!

3 Likes

Thank you - you have just made my day!

1 Like

@nillad, your topic has been moved to a more suitable location on the forum. A little late, I know.