Check out the circuit just below this post "Automotive Ideas" Since you understand the comparitor idea, you should be able to adjust the circuit posted there to 24 volts. As an alternative, do a web search for "comparitor circuits" I am sure you will find exactly what you want.