Help with analog read

Hello All,

I am working on Arduino Mega (Arduino in the picture is for reference)

I am a newbie to Arduino world and have a question. I am working on a project where I have to apply a current between two electrodes and measure voltage at all the remaining electrodes (all the electrodes are placed in an electrolyte bath) in the setup. I have attached a picture showing my setup.

Here each of the electrodes is connected to an analog and a digital pin. (Electrode-1: A0-13, Electrode-2: A1-12, Electrode-3: A2-11 etc) Picture attached.

When I want to pass current through electrodes 1 and 2 I am assigning OUTPUT-LOW to the digital pin connected to electrode 1 and Input_pullup for the electrode 2. I am making rest of the electrodes as input and performing the analog read. When I connect the electrode to Digital 1and analog 1 I am getting some numbers. But when I connect the electrode between A0 and digital 13 and trying the same logic I am getting zeros everywhere. Can anyone help me understand the reason why when the pins are connected A0-0, A1-1, A2-2… its working and failing to give anything when connected between A0-13, A1-12 so on??

One more question is when I connect the electrodes between the digital 1-A1 and digital0-A0, I am unable to upload the sketch. What is the reason for this?

Also posted at: https://arduino.stackexchange.com/q/55517 If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

Armydroid: Here each of the electrodes is connected to an analog and a digital pin. (Electrode-1: A0-13, Electrode-2: A1-12, Electrode-3: A2-11 etc) Picture attached.

Why not use a single pin? Analog pins on the Mega are also digital.

One more question is when I connect the electrodes between the digital 1-A1 and digital0-A0, I am unable to upload the sketch. What is the reason for this?

Because 0 and 1 are the serial interface. Much simpler to avoid using them for anything else. They may be pulled up hard by the USB serial interface which accounts for seeing actual voltages with digital pin 1.

The internal pullups are very weak (20k to 50k) and non-linear - they are no actual resistors on chip to do this, only pFETs with long narrow channel.

What you probably should be doing is adding a series resistor of a suitable well-defined lowish value to every pin, so that you get enough current to the GUT (gloop under test!)

Maybe try 1k in series with each analog pin. Switch the driving pins to OUTPUT, set one LOW and the other HIGH, analogRead the other pins (1k series resistance will have no effect to analog readings, analog pins take zero current).

Its also possible to use pairs of pins as you do, but add series resistors for the digital pins to limit current - this would allow you to measure the voltages after the series resistors and thus measure current from the driving pins.