Voltage Divider issue

Hi,

I have made myself a voltage divider using a 4K7 and 1K resistor and it is doing the job as far as I can tell
But the issue is that when I connect 12v to it the arduino is reading 1023, I checked the voltage on the pin when connected to 12v thinking it was not working but the voltage is only 2v
If I connect it to the Arduino 5v pin it reads perfectly

Any Ideas?

int sensor;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
sensor = analogRead(A0);
Serial.println(sensor);
}

Any Ideas?

Is the ground of the 12V connected to the ground of the arduino?

12v Positive is connected to 4K7 Resistor
12v Negative is connected to 1K Resistor
Both Resistors are connected to Analogue A0

That has not answers the question. Is the -ve 12 V connected to the arduino ground? It need to be or it will not work.

Sorry it was not connected, thanks for your help :slight_smile: