There is a voltage between1.5 - 2 volts between the digital (and sometimes analog pins) and Ground of the Arduino Uno I am using , it's only there when I plug the Arduino via a usb cable to a desktop or laptop , that voltage goes way down to a few millivolts when I use an external battery to power up the Arduino.
That voltage of 1.5 to 2v isn't normal I am assuming -
Measurements were taken when the Arduino wasn't programmed to do anything .
Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE
The 5V that is coming from PC is a rectified DC voltage and it contains ripples (acceptable amount) which appear on the physical pins (PPin) of the MCU of the UNO Board.
In contrast, the Battery voltage is completely ripple free; as a result, you observe very stable low voltage on the Apin/DPin of the Arduino Board. The APins/DPins of the edge connector are shorted with PPins of the MCU via PCB tracks.
If you don't program your pins like in #6, the pins will be floating (high impedance),
and can have any value between o and 5v (if its a 5v Arduino. Try to measure a pin and at the same time touch the pin with your finger - by that you can change the reading.
So if you don't want the floating values, you have to initialize the pins (#6)
I believe I found the issue but here's the reply I was going to send earlier about what was going on :
While connected to a laptop or desktop via USB :
The Arduino's pins show a voltage of 1 to 2v with respect to ground. (Not there when a battery is powering Arduino )
And this while it's not doing anything , no code - it's in the 'tabula rasa' state.
When I set a pin as an INPUT then digitalWrite that pin 'LOW ' , the voltage stays at that level , id est : 1.5v to 2v
(jumps to 2 volts when I touch the probe with me finger).
But when I set that same pin as an OUTPUT and digitalWrite to 'LOW' , the voltage instantly drops to 0.001 on the multimeter and stops dancing around .
So while connected to a pc : it only goes to Zero volts when I set the pinMode as an OUTPUT , not as an INPUT .
What I think is happening :
With a battery powering the Arduino however , or right after I disconnect the laptop's AC power cable , the voltages go down to the mVs range.
I am using ungrounded outlets here and the contactless AC voltage detector goes nuts whenever I go near the laptop or desktop with it.
Heck the AC beeper goes crazy even when it is close to the Arduino itself .
Unless setting a pin to digital LOW means something other than a strict 0 Volt or at least near it , which is what my question boils down to at this point , I believe it's the ungrounded outlets that are causing this .
when you set your pin as an INPUT and set it to low, you removed the pull-up (in case it was there). So now your pin is floating and is like an antenna. Its voltage will vary a lot. Your measure is probably just an average of what's really happening.
if you set the pin as INPUT_PULLUP, you will read 5V
when you set it as an OUTPUT, then LOW or HIGH will define the voltage and that's what you see.
At the very first reading, I have got confusion as to how data bit could be written onto an input line! When I have looked into the details of 1-bit structure (Fig-1), I have got it cleared that the data bit is written on the internal latch (Fig-1) which disables the AND gate and eventually takes out the internal pull-up resistor from the input line. Bravo!