How do i choose the resistors?
There is a calculator online at **broken link removed**
Perhaps R1 could be 60 ohm and R2 could be 40 ohm to end up with 4.8V from 12V.
If the car battery was charging and the voltage of the system went up to 16V, perhaps I should adjust the values a bit. So, say the worst case scenario is 18V, presumably I'd run the resister calculation at 18V in which case I'd get R1 60 ohm and R2 23 ohm and end up with 4.988 V output. But at 12V input I'd only end up with 3.325 V output. Will the GPIO on the PIC still work at 3.325 V? How low can you go with the voltage?
The other question is, how do you know what size to make R1? According to the PICAXE schematic above, R1 is 3300 ohm and R2 is 1000 ohm. You'd end up with between 2.791V from 12V and 4.186V from 18V. But I could end up with exactly the same voltage divider with any value for R1. Is 3K3 an appropriate value for the PIC?
I presume the size of R1 has to do with how much current you want to make available to the PIC GPIO pin and probably has to do with R=V/I.