Dificuldade em medir voltagem correcta após ligas reles ao GND

Boas tenho o seguinte codigo elaborado para medir voltagem de um pilha mas verifico quando ligo o GND dos reles ao arduino a leitura da pilha deixa de ser correcta como posso resolver este problema?

#include <LiquidCrystal.h>
//#include <Wire.h>
//#define SLAVE_ADDRESS 0x40 // Define the I2C address to Communicate to Uno

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;

// For V1.0 comment the other threshold and use the one below:
/*
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/

return btnNONE; // when all others fail, return this…
}

int VoltageSensor = A1;

// Comunication
//char ReceivedData[128];
//char Response[128];
//bool DataReceived;

int POSBloco = 1;
int POSCelula = 1;
float VoltBloco1[15];
float VoltBloco2[15];
int Last;

void setup(){
Serial.begin(9600);
analogReference(DEFAULT);

lcd.begin(16, 2); // start the library
lcd.setCursor(0, 0);
lcd.print(“SLApps Solutions”); // print a simple message

for (int thisPin = 22; thisPin < 50; thisPin++) { pinMode(thisPin, OUTPUT); }
for (int thisPin = 22; thisPin < 50; thisPin++) { digitalWrite(thisPin, HIGH); }

ScanPorts();

//Wire.begin(SLAVE_ADDRESS);
//Wire.onReceive(ReceiveData);
//Wire.onRequest(SendData);
}

//3.73
void loop() {

//Serial.print("Voltage - ");
//Serial.println(GetVoltage());

//lcd.setCursor(9, 1); // move cursor to second line “1” and 9 spaces over
//lcd.print(millis() / 1000); // display seconds elapsed since power-up

//lcd.setCursor(0, 1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
Last = 0;
if (POSCelula < 14)POSCelula += 1;
Display();
break;
}
case btnLEFT:
{
Last = 0;
if (POSCelula > 1)POSCelula -= 1;
Display();
break;
}
case btnUP:
{
Last = 0;
if (POSBloco < 2)POSBloco += 1;
Display();
break;
}
case btnDOWN:
{
Last = 0;
if (POSBloco > 1)POSBloco -= 1;
Display();
break;
}
case btnSELECT:
{
Last = 0;
lcd.print(“SELECT”);
ShowScanPorts();
break;
}
case btnNONE:
{
Last++;
//lcd.print("NONE ");

break;
}
}
delay(100);
Display();
Serial.println(Last);
if (Last == 100) {
ScanPorts();
Last = 0;
}
}

void Display() {
lcd.clear();
lcd.setCursor(0, 0);
String Message;
Message = “Bloco:”;
Message += POSBloco;
Message += " Cel:";
Message += POSCelula;
lcd.print(Message);

lcd.setCursor(0, 1);
lcd.print("Voltagem ");
if (POSBloco == 1)lcd.print(VoltBloco1[POSCelula]);
if (POSBloco == 2)lcd.print(VoltBloco2[POSCelula]);
}

void ScanPorts() {
int Count = 0;
POSBloco = 1;

int POSB = POSBloco;
int POSC = POSCelula;

for (int Porta = 22; Porta < 50; Porta++)
{
GetVoltage();
Count++;
digitalWrite(Porta, LOW);

Serial.print("Scan porta “);
Serial.print(Porta);
Serial.print(” - ");

if (POSBloco == 1)VoltBloco1[Count] = GetVoltage();
if (POSBloco == 1)Serial.println(VoltBloco1[Count]);

if (POSBloco == 2)VoltBloco2[Count] = GetVoltage();
if (POSBloco == 2)Serial.println(VoltBloco2[Count]);

delay(100);

digitalWrite(Porta, HIGH);

if (Count == 14) {
POSBloco = 2;
Count = 0;
}
}
POSBloco = POSB;
POSCelula = POSC;

Display();
}

void ShowScanPorts() {
lcd.clear();
lcd.setCursor(0, 0);
int Count = 0;
POSBloco = 1;
GetVoltage();
Serial.println("*********************************************");
for (int Porta = 22; Porta < 50; Porta++)
{
Count++;
lcd.print("
");
digitalWrite(Porta, LOW);

Serial.print("Scan porta “);
Serial.print(Porta);
Serial.print(” - ");

if (POSBloco == 1)VoltBloco1[Count] = GetVoltage();
if (POSBloco == 1)Serial.println(VoltBloco1[Count]);

if (POSBloco == 2)VoltBloco2[Count] = GetVoltage();
if (POSBloco == 2)Serial.println(VoltBloco2[Count]);

delay(100);

digitalWrite(Porta, HIGH);

if (Count == 14) {
lcd.setCursor(0, 1);
POSBloco = 2;
Count = 0;
}
}
POSBloco = 1;
POSCelula = 1;

Display();
}

float GetVoltage() {
float Value;
for (int i = 0; i < 100; i++) {
Value = analogRead(VoltageSensor) / 1023.0*5.045;
}
return Value;

}

float GetTemp() {

}