Look at you, Bill: Answering questions complete with sample code!
"Indeed, you are powerful" --Darth Vader
Good for you!
"Pass on what you have learned" --Yoda
...I should stop now, huh? :-)
thanks.
i have a code mechanics question...
Why do i need the saber_is_on (or any bool statement) to be set to false in the setup,.. when i am declaring it false after the if statement?
example:
bool saber_on
void setup
saber_on = false;
void loop
{
if(digitalRead(button) == LOW) //button is pressed
{
if(saber_on) //Saber is on, so turn it off
{
//ADD CODE HERE TO TURN OFF THE LED AND PLAY OFF SOUND
saber_is_on = false;
}
else //Saber is off, so turn it on
{
//ADD CODE HERE TO TURN ON LED AND PLAY ON SOUND
saber_is_on = true;
}
}
}
so,.. it has been declared false in the set up AND after the if statement? Double false? isn't that a true? why cant i just have this and ditch the bool altogether?
void loop
{
if(digitalRead(button) == LOW) {//button is pressed
send_command(0); // off sound
delay(100);
}
else //Saber is off, so turn it on
{
send_command(1); //on sound
delay(100);
}
}
//end
i am pretty sure i started with that type of code, and when the button was toggled, it repeated like crazy.... "ma-ma-ma-ma-ma-ma" mamasita que es pasando!"
i am going to re-test,.. and i like your != simple debounce variant. simple. i'll try it.