Hello, recently i wrote this code which every time you press the button, the pin state will be ON or OF, here's the code:
if ( Fstat == LOW ) //If F key pressed
{
digitalWrite(Fan, !digitalRead(Fan)); //Invert the Fan relay State
}
The problem is when you press the button, if you keep pushing it, it will toggle the pin state as fast as Arduino can read the code, I cant describe it good but you know what I mean.
What I want is to toggle the pin state only once after I pressed the button and then toggle again when I released the button, and pressed it again.
How should I do it?
(sorry I still feel I didn't said what I wanted good, but ask me where you didn't understand)