There are several questions close to this topic already, but they are either for another µC family, or target reading analog voltages or other special cases.
So here goes: I would like to read a button and drive a LED from the same I/O pin on the ATmega32U4. Is there anything wrong with:
- Pin => 22K resistor => button => GND
- Pin => LED resistor => LED => GND
Then of course the pin would be put into input mode (with internal pullup) ever so often, and be in output mode most of the time.
As far as I can tell, the internal pullup is 50-100K on that µC, so the 22K with the button should be able to sufficiently sink that.
In output mode, when the button is not pressed, all is as normal; if the button is pressed, this will add a path through 22K to GND, which might or might not make the LED slightly darker; anyhow, in my application it would not matter at all how the LED looks while that button is pressed.
Any chance to damage anything? Any pitfall that is not obvious?