Problem measuring car OBD1 voltage output

First off, my name is Ha and this is my very first post in this forum. I am very new to Arduino yet have basic knowledge about microcontroller, resister, caps and those kind of simple electronic components.

MY PROJECT I am making a simple gear position indicator for my car. my car has OBD1 connector and has a terminal named TT, when the car runs voltage between TT and E1 (Earth) varies when the tranny shifts. the below table is from repair manual

the tasks looks simple: keep measuring voltage between TT and E1 and indicate related gear position to a 7 segment led.

TEST LAB I built a bench test on breadboard with voltage devider on Arduino Leonardo, it simply reads analog voltage from pin A0 and it works fine showing correct calculated voltage of a 9v battery to serial output.

I then connect a pot to the circuit, when I adjust pot resistance, serial output show voltage gradually up and down nicely.

PROBLEM But when I connect the test board to pin TT & E1 on car and run it. serial output showed only 2 value 0 or sparks of 6volt (approx.) every now and then INSTEAD OF a series of voltage gradually increase from 0 to 6.xx as it was when I used a multimeter in place of the Andruino board.

I dont know where to start at to fight the problem. please share your ideas

Just a thought, common ground to the arduino, from the obd1 plug ?

please explain a bit more, i am newbie. The E1 terminal is grounded to car I think. should there be another ground connected to car chasis? thanks

any more thoughts please, got 500+ reads, no more help

found the answer. the problem was that I used very basic code to measure voltage momentarily. it worked for stable voltage source like a battery and a potentionmeter but it will NOT work in real life environment in car. I had to re-write the code to average out 500 readings for every single result. lesson learnt.

problematic sketch: This sketch works in lab environment
// setting up TT input reading
const float referenceVolts = 5; // the default reference on a 5-volt board
const float R1 = 10000;
const float R2 = 4700;
const float resistorFactor = R2/(R1 + R2);

void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
float volts = sensorValue * referenceVolts / 1023/ resistorFactor;
Serial.println(volts);
delay(100);
}

Working sketch:
// setting up TT input reading
const float referenceVolts = 5; // the default reference on a 5-volt board
const float R1 = 10000;
const float R2 = 4700;
const float resistorFactor = R2/(R1 + R2);

void setup(){
Serial.begin(9600);
}

void loop(){
int sensorValue=analogRead(A0);
long sum=0;
for(int i=0;i<500;i++)
{
sum=sensorValue+sum;
sensorValue=analogRead(A0);
delay(2);
}
sum = sum/500;
float volts = sum * referenceVolts / 1023/ resistorFactor;
Serial.println(volts);
delay(100);
}