I'm trying to make a compact prototype with Attiny2313A, and want to connect VCC to pin 18 with a push button as in the picture. Is it safe? Or do I need a resistor there?
Asked
Active
Viewed 92 times
0
-
4As long as the pin is configured as input, its save. Though you need a pulldown resistor in that case, or your pin will be floating, when the button is not pressed – chrisl Apr 12 '21 at 06:36
1 Answers
3
As mentioned by @chrisl, here you would need a pull-down resistor to make sure that pin was not high when the button was not pushed.
It is more typical to connect the button between the IO pin and ground since then you can use the built-in pull-up resistors to make sure the pin is high when the button is not pushed. (This chip only has built-in pull-ups, although some chips have pull-downs).
bigjosh
- 1,553
- 10
- 12
-
In some cases I'll series something like 150 Ohms with the I/O pin. It's not enough resistance to negatively affect the function of the circuit (it is small fraction of the pullup resistance value), but it's enough to limit current to a reasonably safe level in case something goes wrong in software and the pin becomes configured to output high. – timemage Apr 12 '21 at 22:03
-
@timemage In practice, this is almost never necessary in ATTINY chips. If you were to somehow accidentally set the button pin to an OUTPUT pin and drive it high, and then press the button so that pin was shorted to ground, then the chip would quickly undervoltage reset, which would set the pin back to an input. – bigjosh Apr 14 '21 at 03:19
