Why doesn't this simple Push Button Circuit work?

I'm trying to create a simple circuit where an Arduino can read when a button has been pressed - through Analog Input port A1 - and print the result through Serial.print().

I've been able to get the results I'm after - using a different circuit - but I really want to know why this this particular circuit doesn't give me the expected result.

Expected Result:

  • Arduino prints a value between 0 and 1023 when the button is pressed
    Actual Result:
  • Arduino prints 0 when the button is pressed (and when it isn't pressed, obviously)

UPDATE:
I should have mentioned that the idea of this circuit is to eventually attach multiple buttons and use resistors to determine which button has been pressed - through the Analog input A1. I have attached another photo (image 2) - obviously this circuit doesn't work either. To get this circuit to work all I had to do was place a resistor to GND where all of my yellow wires meet - on the left - and remove the black wires (see image 3). What I don't understand is why the resistor makes the circuit give the expected result?

broken_circuit
broken_circuit2
broken_circuit3

How about connecting A1 to the point between the resistor and the button. (now it is just connected to GND)

So that would work - but what about when if I wanted to add another button to the circuit?

I think I should edit my question a bit.

EDIT:
Actually, are you able to tell my why simply connecting it to GND doesn't give the expected result?

Well that would mean the resistor is between 5v and A1, which is then connected to GND. That will result in 0v

You clearly show the A1 pin connected to ground. So it will always read (near) zero.

The more appropriate way is to connect the switch between the input and ground and set the pinMode for that pin to INPUT_PULLUP. You may or may not need to add a pull-up resistor to 5 V if there is any reliability problem.

Why are you using an analog pin and analogRead? Buttons are read using digitalRead,

In what way do you expect to do that?

I've updated my question a bit. The idea was to build a circuit that could detect multiple button presses - but I got stuck with just 1 button in my circuit.

You clearly show the A1 pin connected to ground. So it will always read (near) zero.

Are you able to elaborate on this a little, or point me to a reference where I can read a bit more? My understanding of how current/voltage flows through a circuit obviously needs some educating.

Hi, @goochy13
Welcome to the forum.

Have you got a DMM?

Tom... :grinning: :+1: :coffee: :australia:

An analog input responds to the voltage between GND and the analog pin. If you connect the pin to GND it measures zero because there is no voltage between GND and GND.

Steve

Hi, @goochy13
You would be better off reading and drawing schematics to see how a circuit works.
Even a hand drawn circuit can help.

Preferred configurations are;

Tom... :grinning: :+1: :coffee: :australia:

1 Like

Tom, why is it OK for you to ask for a real schematic, but not PaulPaulson?

I frequently ask for real schematics because I won't even begin to decrypt a Fritzing picture.

I have no idea....

Tom... :grinning: :+1: :coffee: :australia:

Because this

Hello
Post a real schematic.

is dismissive, condescending and completely unhelpful. Clearly by the question (and the breadboard image) I had no idea what a "real" schematic is nor how I would draw one. The bread board was something physical I had in front of me and made sense to be able to draw. There's nothing more discouraging than this kind of response - no reference on what a "real" schematic is, no details on how to better make the question easier to understand, just a dismissive comment.

An analog input responds to the voltage between GND and the analog pin. If you connect the pin to GND it measures zero because there is no voltage between GND and GND.

This makes sense to me, thank you @slipstick .

@TomGeorge
Appreciate you showing me how the circuits should be drawn. That's above and beyond what I expected.

Question has been answered, thanks.

Yeah i know. It happens all to often. You do see that the shots that you posted are a lot more difficult to read though, and that people who want to help, would like the information provided in the most clear way. Many times, a circuit schematic is clear enough that the questions just disappears by itself. Most people that respond on this forum are genuinely trying to help, though at times for egotistical reasons, and are of course also absorbed in their own day to day life, which may result in less than tactful phrasing. (What i say after 4 beers may not be quite what you want to hear, just before lunch)

There is.... No response at all !

Some kids grow up with parents who are 'just like that' , some kids grow up without any parents at.

Anyway, glad to see you got it all sorted. This forum, and other forums like this (this is far from the worse i've encountered) can be a bit like this, and believe it or not, some people respond better to gung ho responses than to sensitive and explanatory ones.