4
\$\begingroup\$

I am reading a book called Getting started with Arduino. In that book, I don't understand why there is no resistor between pin number 7 and the switch (see diagram:)

Arduino-breadboard diagram

If there is no resistor between power source and ground, wouldn't it be prone to short-circuit and cause damage? Does pin 7 contain a built-in resistor or something?

\$\endgroup\$
  • \$\begingroup\$ This is a silly example. AVR's have internal pullup resistors, that are very easy to enable. Much easier to connect the button to ground and enable the internal pullup, versus connecting it to 5V with an external pulldown to ground. \$\endgroup\$ – davr Apr 11 '11 at 16:03
8
\$\begingroup\$

Your hypothesis is correct: in input mode, the pins have very high impedance, somewhere along the range of 10s of mega ohms. So there will be little current flowing into pin 7, and it is OK to use it as is. Note that pin 7 is NOT ground so there is no short circuit between power source and ground.

When you press the switch, current will flow primarily through the resistor. The voltage will rise and will be seen by pin 7 as a digital high.

| improve this answer | |
\$\endgroup\$
4
\$\begingroup\$

It's not exactly a built-in resistor. The input pin is internally connected to the gate of a MOSFET. Now a MOSFET's gate is floating as they call it; it's insulated from the FET's channel. This means that an incoming voltage has no way to go, so there will be no current, (apart from a negligible leakage current). This means that you can make voltage and current calculations for the switch-resistor circuit as if it's not connected to the input pin at all.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.