You're almost there... But why did you duplicate analog value reading ? Why two "prevState" variables ? That will just make the code less clear and more error-prone.
You're almost there... But why did you duplicate analog value reading ? Why two "prevState" variables ? That will just make the code less clear and more error-prone.