Hey,
I've got a question for this example
shouldn't there be a current limiting resistor between the 5V and the Button?, otherwise I would shorten the circuit and the maximal current of the 5V would rush into the Arduino input pin?
Hey,
I've got a question for this example
shouldn't there be a current limiting resistor between the 5V and the Button?, otherwise I would shorten the circuit and the maximal current of the 5V would rush into the Arduino input pin?
No. The Arduino input pin is a high impedance, giga ohms. The only current inrush is the tiny, short burst of current that charges the tiny internal capacitance of the pin.
My only complaint, is that "How to Wire [...] a Button" suggests one of the worst ways to connect a button... resistor pull down, as do the other examples, except for the "InputPullupSerial" example:
There is no pedagogic explanation, I can only assume that they think people are too stupid to absorb the idea of a button press that produces a LOW when pressed.
I see this as a missed opportunity to teach an important digital fundamental - the indifference of logic systems to the choice of representation (big words for a simple idea, though).
thx a lot :).
There's a schematic demonstrating the several ways to wire the button and ranks the options:
Does someone have the canonical link to this diagram and any discussion around it? (ETA: Share tips you have come across - #999 by LarryD -- There's some discussion there and at https://forum.arduino.cc/t/wiring-a-button-pull-down-bad-vs-input-pullup-best/116298566 )
The Arduino tutorial chooses the BAD S1 wiring:
pinMode(2,OUTPUT);
would, when the button is pressed, short the 5V to ground through the Arduino, potentially sinking more than the 40mA limits on pins.
Here's some code that, if properly edited, could demonstrate the hardware vulnerability of pull-down button wired Arduinos to malicious software:
void setup(void) {
for ( int i = 0; i <= NUM_DIGITAL_PINS ; ++i) {
// pinMode(i, 0UTPUT) // smoke-test for non-current limited 5V inputs
}
}
void loop(void) {
}
Maybe the pull-down tutorial advice helps sell replacement Arduinos?
ETA: Nick Gammon has a tutorial:
AVR datasheets tell about INPUT sampling. IIRC it is about 1 microamp per read but maybe that is analog read, both look electrically neutral the rest of the time.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.