Wawa:
With that length of wire you might need stronger pull up, like a 1k resistor.
And a 100n ceramic cap from pin to ground.I assume you have used shielded or twisted wiring for your sensor (Cat-5). Not just twin flex.
Never a good idea to run low voltage wiring next to mains power wiring.
Leo..
Even after using capacitor, arduino still switches off the motor when i turn on my fan or turn it off. Is there any other way. Thank you.