With optocoupler you will obtain Total isolation from the 5 volts rail and total immunity to noise.

Cheers

Al.