# Voltage Divider for measuring more than 5V

I followed this tutorial but i have no clue why it’s not working
http://startingelectronics.com/articles/arduino/measuring-voltage-with-arduino/
You can find the code here ^
I’m working with Arduino UNO

anyone knows what seems to be the problem ?  but i have no clue why it's not working

You didn't post any code. You didn't say what size resistors you are using. You didn't say what the code does, or what it is expected to do. No clue is right.

Wrong.

You didn't say what the code does, or what it is expected to do.

Try again.

I’m using 1Mohm + 100KOhm Resistors

The code measures the voltage from the analog pin and display it on serial moniter
here is the code:-
// number of analog samples to take per reading
#define NUM_SAMPLES 10

int sum = 0; // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0; // calculated voltage

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

void loop()
{
// take a number of analog samples and add them up
while (sample_count < NUM_SAMPLES) {
sample_count++;
delay(10);
}
// calculate the voltage
// use 5.0 for a 5.0V ADC reference voltage
// 5.015V is the calibrated reference voltage
voltage = ((float)sum / (float)NUM_SAMPLES * 5.015) / 1024.0;
// send voltage for display on Serial Monitor
// voltage multiplied by 11 when using voltage divider that
// divides by 11. 11.132 is the calibrated voltage divide
// value
Serial.print(voltage * 11.132);
Serial.println (" V");
sample_count = 0;
sum = 0;
}

The code measures the voltage from the analog pin and display it on serial moniter
here is the code

So, what is the problem? What is the voltage coming from?

I'm using 1Mohm + 100KOhm Resistors

Pretty high values...

The problem that i'm getting random values, not what i really want

I'm currently testing on a 9V battery, but i want to measure different, maybe higher voltages later

What values do you suggest, and how do you see the code and the connection, Is there a problem there ?

When you say random values, what do you mean?