Best way to monitor on/off state with a microcontroller
I think a optocoupler (opto-isolator) is the way to go. Since there is no physical connection between the 24V and the MCU, when using an optocoupler, the chances you blow up your MCU are way smaller (as example: unknown current/voltage spikes in the 24V line).