You set it as INPUT and do a digitalwrite HIGH to the pin.
QuoteYou set it as INPUT and do a digitalwrite HIGH to the pin.What that accomplishes is to enable the pullup resistor, not turn the pin on.
The difference between an INPUT pin, where some external source is supplying the voltage, and an internal pin that is set HIGH or LOW is that one can reasonably assume that the switch is pressed if the voltage is present, and not pressed if there is no voltage present (in a pulldown resistor situation) or the reverse (in a pullup resistor situation).If the pin is set as OUTPUT, the HIGH/LOW state is dependent on what digitalWrite() was used to set it to, not on whether there is something consuming the voltage/current supplied to the pin.
I only have one question left: Why is there a separated 5v wire? Why not power it by the same pin 2?
So to get power to an input pin you just do a digitalwrite HIGH to the pin and the pin is powered via a pull up no extra resistor needed.
QuoteSo to get power to an input pin you just do a digitalwrite HIGH to the pin and the pin is powered via a pull up no extra resistor needed.No. The digitalWrite() function, for an INPUT pin turns on or off the pull-up resistor. It does NOT turn the pin HIGH or LOW. Only OUTPUT pins can be set (forced) HIGH or LOW.
What does a pull up resistor do?
QuoteWhat does a pull up resistor do?For low currents, it pulls up to (or very near) the supply rail.But it limits the current available.
Thank you AWOL you just proved my point.
QuoteThank you AWOL you just proved my point.Do you mind me asking what your point was?(bearing in mind that the pull-ups are in the range 20 to 50 kOhm)
Yes, but a couple of hundred micro amps at five volts is not what first comes to mind when someone mentions "power".