im trying to programm a simple play button with a normal pushbutton(not permanent).
please tell where my logic is wrong.
It should just start when pushed once, when I push him again it should stop.
currentplayState = digitalRead(playPin);
if (currentplayState == 1 && playing == 0) {
playing = 1;
}
if (currentplayState == 1 && playing == 1) {
playing = 0;
}
if (currentplayState == 0 && playing == 1) {
playing = 1;
}
//Main sequence
if (playing == 1) {[...
}/code]
big thnx
I'm going to guess that the issue is that it's going on & off more times than you expected. In which case, you will need to debounce your button. Lots of examples of this in tutorials & forum posted code.