Nimm nen Optokoppler und gut ist.