I can see how easy reading upto 5v is, but I want to measure upto 20v. How can I do this?
Look up voltage divider.
As wildbill says, voltage dividers will cut the voltage down to a readable range. There are some possible hazards tho. If the resistor connected to ground gest ajar (loose), the ic will probably fry. You should have a schottky diode on the analog input pin to prevent destruction of the IC.
Okay, so it seems that will divide it based on two resistors used.
But won't that use lots of power? Resistors to ground I mean?
Is there another way, as I want to use it to measure voltage on a solar panel system.
Or is this a trival amount of power wasted?
It depends on the value of your resistors.
Just roughly, use 10k on top, and 3k on the bottom. that will not draw much power. You can do the math later, but that should be a starter.
Thanks. I'll try that