Switch monitor Project


I’m using a Adafruit Metro Mini 328 board. I’m monitoring the status of a switch on a truck and sending outputs to another device when the switch has been turned on.

My issue with this is the truck has been giving false “ON” and False “OFF”. I think there is interference on the line I’m monitoring. When the switch is OFF it must be getting voltage spikes causing the board to think the switch has been turned ON, Once it goes it away it Switches back OFF.

I’ve added delay and state detection in and it’s helped but still doesn’t seem like it solved the problem. I’m hoping someone can check out the code and make any suggestions that could help improve the way I’m doing this.

Find the code attached. Thanks in advance for any help at all!

PTO_5-26-16_latestREV.ino (2.57 KB)