Recommended · for beginners
Using Optocouplers with the Raspberry Pi
Why people recommend it
Explains how an optocoupler isolates a Raspberry Pi from motors, pumps and other noisy loads; answerers recommend it as a clear account of how the part works.
Watch for: the LED side needs a current-limiting resistor
In their words
Take a look at the Youtube video for more detailed info
Mats Karlsson on raspberrypi.stackexchange.com, Sept 2020. CC BY-SA.
Using Optocouplers with the Raspberry Pi
Steve Robillard on raspberrypi.stackexchange.com, Oct 2017. CC BY-SA.
Instructions and video can be found here:
Ziomuś Gorliczanin on raspberrypi.stackexchange.com, Sept 2019. CC BY-SA.