Optocoupler with the same power supply
No, there is no good reason to use an expensive and large optocoupler if you're sharing ground. The optocoupler's prime advantage is isolation. The common use of this appears to be cargo cult adoption from cheap expansion kits for development boards. You can protect the pin with cheaper discrete components, or multiple &quot;discrete components&quot; integrated into a small package.