analog voltage not 0V when digital pin connected to analog pin set to LOW

Hi I am exploring the ADC pins on a Nano board. I have connected 4 digital pins to 4 analog pins. On setting digital write to LOW I get about 3V reading. Why do I not get 0V. I have checked and there is 0 ohms between the two ground pins and the outer casing of the USB supply. I get no difference in reading if I swap the supply from laptop to 5V wall socket supply. Any help would be appreciated


pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(3, OUTPUT); pinMode(3, OUTPUT);
digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,LOW); digitalWrite(5,HIGH);

float temperature_measurement(int pin)
// analogReference(INTERNAL);
float Temperature = 0;
float avtempRead = 0;
for (int i = 1 ; i< 101 ; i++ ){
delay (20);
avtempRead += analogRead(pin)*(5000.00/1024.00) ;
// avtempRead += analogRead(pin);
Temperature = avtempRead / 100000.00 ;
return Temperature;

void loop(void)

float temperature2; float temperature3; float temperature4; float temperature5;

temperature2 = temperature_measurement(A2); temperature3 = temperature_measurement(A3); temperature4 = temperature_measurement(A4); temperature5 = temperature_measurement(A5);

I have just noticed that not all the digital pins had the corresponding PINMODE set. When I corrected this mistake everything seemed to work correctly.

I guess you copied and pasted pin3's pinMode then....

Yes. I have checked my code more than once and I obviously read what should be there rather than what is there.

Thanks for your support JimboZA