Using arduino inputs more reliably

We would already know that if you had posted the requested diagram.