I have a Arduino Uno with 14 digital pins. I believe they have an output of 5V. But they can also input values. I'm not sure of what exactly it reads when it does that (amperage, voltage ...). Also, how do they read it? How can such a tiny thing possibly know what it's receiving?

Just to provide a little more context to the reading part of this question, here's an example circuit. I have a 5V battery connected to an LED and a 220 Ohm resistor. Next thing in the circuit is a wire, which exits the main circuit and connects to a digital pin on the Arduino Uno (here it reads the value). Then the main circuit closes by connecting to ground.

Hope my question is clear enough :)

  • 3
    @NickAlexeev - there's nothing "Arduino" about this question to justify migrating it. It's really a "how does a microcontroller work" question. Oct 6, 2014 at 16:15

3 Answers 3


Modern digital electronics is made from many tiny electronic components called MOSFETs (a type of transistor). They can be switched on and off using a voltage, and a very small amount of current. They use the majority of the power when they are switching on and off; the rest of the time they use virtually no power. It this very low-power capability which allows us to make complex digital electronics.

Electronically, a MOSFET looks like a tiny capacitor, which triggers a very low-power switch, on and off. Once there is charge on the MOSFETs capacitor, the switch will stay on or off.

A modern large-scale processor, for example the type of device Intel makes, contains billions of MOSFETs, but requires less than 100W, and switches billions of times/second. So we can be confident that a MOSFET can be switched using much less than 1/10,000,000W. At 5V, that means 1/50,000,000A, or 0.000,000,02A, i.e. 0.02µA.

So, the input circuit, connected to an Arduino's pin has some protection, to protect the MOSFETs from static electricity (which could damage or destroy the capacitor), then a complementary pair of MOSFETs (called N-Chanel and P-Chanel). The input voltage switches one on, and the other off. It typically requires less than a micro-amp of current, but at a voltage close to ground or 5V. See pjc50's diagram.

So an Arduino input pin, connected to the 5V end of the resistor and LED will take a tiny amount of current, for a short time, to switch on.

If that pin is connected between the LED and resistor, at some voltage less than 5V, but more than 0V, then it might not switch fully. It might not give a reliable value of digital 0 or digital 1, and might switch high and low rapidly influenced by electrical noise in the environment.

  • Great explanation, thanks for taking your time to write this! Oct 6, 2014 at 17:12

It measures voltage.

The input circuit is conceptually similar to this:

CMOS input

  • Voltages close to 5V will turn the lower transistor on and the upper one off.
  • Voltages close to 0V will turn the upper one on and the lower one off.
  • Voltages in the middle will turn both on to some extent, which is not recommended, and may be read as either 0 or 1 with a threshold in the middle.

"Such a tiny thing" contains tens or hundreds of thousands of transistors.

  • Great explanation, the image is really useful! Oct 6, 2014 at 17:12

If somebody(like me) is looking for a explanation in terms of registers, the voltage at a pin when it's a digital input can be accessed with the PINx register, with a bit being used per a pin. Based on the value in the specific bit of the DDRx register, if it's 0 (an input), the voltage at the pin is represented by the bit in the PINx. When it's 1 (an output), the bit at the PINx register will be the value in the PORTx register for the specific bit(the value written). If the bit in the DDRx register for the pin is 0(an input), the bit in the PORTx register represents whether the internal pull-up resistor should be connected to the pin. x is used to mark the port (A,B, for example).

Edit: I've started working with the ATtiny10 for a specific, but most likely just-on-paper project. It has the separate PUEx register for the internal pull-ups. It has only 6 pins, with 4 or those being accessible as GPIOs. The pins have specific modes where every pin requires slightly different flag changes for changing the mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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