I've seen this in many tutorials introducing switches,
However, when pushing the button, the Arduino's pin voltage is about 5V! That's not good!
Am I missing something?
I've seen this in many tutorials introducing switches,
However, when pushing the button, the Arduino's pin voltage is about 5V! That's not good!
Am I missing something?
That's not good!
Why not?
redraw:
Am I missing something?
Yes, this page says:
Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts.
However, when pushing the button, the Arduino's pin voltage is about 5V! That's not good!
Yes that would not be good if you ever made the pin an output, then made it LOW, then pushed the switch.
If you can't trust yourself with pinMode then this could be safer.
This explains the two ways to wire up a push button.
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
redraw:
I've seen this in many tutorials introducing switches, ... Am I missing something?
Yes. You are missing out on a great deal of knowledge. Those tutorials are - sadly - not written by engineers with any particular competence!
that doesn't mean they are wrong, and actually, in this case, they are OK
alnath:
that doesn't mean they are wrong, and actually, in this case, they are OK
They are not OK. That one works but that does not make it OK. There is a lot more to good engineering practice than simple functionality. That applies not only to hardware but to software perhaps even more so.
Regardless of the physical pin / switch / resistor configuration, surely the point we should be making to the OP and which I tried to do in reply #2, is that it's ok to take a pin to 5V (on a 5V Arduino anyway). But as LarryD pointed out, the pin needs to be set as in input with pinMode.
The OP's concern was, after all, about the wisdom of connecting a pin to 5V.
My head was thinking in OUTPUT mode. You're right. In INPUT mode it's fine. It's good to make it clear.
In fact, if I'm not wrong, there's a huge resistance when it's on INPUT mode, as the official web says,
"Pins configured this way are said to be in a high-impedance state. Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin."
So there's no need to add 100-ohm before the pin. Why some people prefer to do that?
So there's no need to add 100-ohm before the pin. Why some people prefer to do that?
Read those replies again they told you.
In case you make a mistake and program the pin to be an output, and program that output to be a zero and press the button.
Well, I read that! but I thought there was ANOTHER reason.
Thanks for your help.