The problem I have is that I can't connect the 24v to a analog pin on a arduino because that's to much for it to handel right?
Sounds like you need a voltage divider consisting of 2 resistors across the battery with the junction between the resistors connected to an analogue pin and the negative terminal of the battery connected to the Arduino GND.
You need to choose the ratio of the values of the resistors so that when the battery is at its maximum voltage the voltage at the junction of the 2 resistors is 5V.