0

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 :)

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

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.

1
  • Great explanation, thanks for taking your time to write this! – PenguinCake Oct 6 '14 at 17:12
1

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.

1
  • Great explanation, the image is really useful! – PenguinCake Oct 6 '14 at 17:12

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.