I'm totally new to Arduino and to electrodynamics in general.

I'm wondering what happens if I connect my digital pin to an analog input on Arduino, and make digitalWrite and analogRead on the according pins. Here are the options I can think about:

• Just connect them directly - it is not a short circuit, is it?
• Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?
• Make a circuit: digital output -> resistor -> ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?

As you see, I'm really confused now. I would highly appreciate if someone could explain in detail what is happening in all the cases, with corresponding values for the current, voltage and resistance.

• The more interesting cases are connecting the input such that there's a resistor between the input and the digital output and another resistor between the input and ground, forming a voltage divider. Or connecting the input to a PWM output via a several kilohm resistor and connecting the input to ground via a several uF capacitor, forming a filter to smooth the PWM duty cycle into an analog voltage. – Chris Stratton Jun 5 '14 at 21:39

You can connect digital pin to analog input directly. That's not very interesting though, since you'll only see two values from the analog input (at least theoretically).

The digital pin gives out 0 or 5 Volts. The analog pin expects 0 to 5 Volts input. The only thing that matters to the analog input is the voltage with respect to ground. That can be between 0 to 5 volts (returned as 0...1023 by `analogRead` function).

Just connect them directly - it is not a short circuit, is it?

No, it's not a short circuit. In general, connecting anything to an input is not a short circuit. Connecting output to another output is potentially a short circuit.

Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?

This makes no difference compared to connecting them directly, unless the resistor value is very high (should be hundreds of kOhms or even MOhms to see a difference, I suppose), because almost no current flows to the input.

Make a circuit: digital output -> resistor -> ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?

This makes no other difference than that the resistor loads, i.e. draws current from, the digital output. If the resistor value is too small, then the digital output is unable to supply enough current so the 5 V voltage could become less than 5 V, or you could even burn the chip.

• Thank you for the detailed answer! I didn't get "you'll see the two values" - not only one, voltage? And I didn't get the last paragraph. Can it be explained with only I = U/R? – roman-roman Jun 4 '14 at 17:39
• You see one value at a time, of course, but the value will be either 0 (digi-out LOW, 0 Volts) or 1023 (digi-out HIGH, 5 Volts). You cannot create, for example, 2.5 Volts with the digi-out, which is either on or off. The last paragraph, yes, I = U/R, and your digi-out has either 0 or 5 Volts, so I = 0 for LOW and I = 5 / R for HIGH digi-out state. If R is small, then I becomes high. The top limit is 20 mA for some Arduinos at least. If you use 250 Ohm R, then you'll get 20 mA from 5 Volts. – Joonas Pulakka Jun 4 '14 at 20:04

If you have a 250 ohm resistor from the digital pin to Gnd, and connect the digital pin to an analog input pin, then 20mA will flow thru the resistor to Gnd (5V/250 ohm = 20mA), while almost nothing flows into the analog input, as the max input current is 1uA per the datasheet, implying the input acts like a large resistor to Gnd: High input of 5V/.000001A = 5Meg-ohm.

I say acts because the input pin is the gate of a MOSFET, and a diode protection clamp to +5 and another to Gnd to limit the input voltage to -0.5 and Vcc+0.5V (so 5.5V with Vcc = 5V).

The diode clamps are only good for ~1mA (not shown in the data sheet, but discussed in an application note on detecting AC zero crossing), exceed that and you risk blowing the diode and/or the input pin and/or the chip (which will then feel warm or hot to the touch when it is powered up).

That's why you don't apply signals to unpowered chips - to prevent damaging the diode clamp circuits.