Galvanic isolation: optocouplers
For sure, you have heard the term galvanic isolation many times. In brief, it’s about separating the source of signal from the microcontroler in order to prevent it from unwanted and dangerous voltage spikes, while allowing to read the signal.
Such a separation is provided by optocouplers. The optocoupler contains in common package both infrared LED diode and photodetector, such as photodiode or phototransistor.
How to utilize this invention? On Australian hacker’s blog there is a tutorial explaining what is an optocoupler and how to read its parameters.