hi guys im trying to make 1st press do1 2st press do2
int counter=0;
if (press) {
if counter=0
{
do1
counter=1
}
else{
do2
counter=0
}
doesnt work
hi guys im trying to make 1st press do1 2st press do2
int counter=0;
if (press) {
if counter=0
{
do1
counter=1
}
else{
do2
counter=0
}
doesnt work
= is assignment, == is comparision
Can we see the actual sketch ?
More thoughts on this, please. Will you ever want to repeat this sequence? Will you ever wait more than two days for the second press?
The simple and elegant way to handle programs like this is with a "state machine"
https://forum.arduino.cc/t/beginners-using-the-switch-case-statement/680177/10
Try writing it in C language.
The logic is solid and should work, you just need to write it in the language arduino can understand
im gonna test it (with ==) on a push button (problem can be on component i use)
Use millis timing (blink without delay example) instead of changing pin state change press state to 0,1,2. For no press, 1 press, 2 press. Millis timer starts with edge detection on first press, which you have to debounce, you then need to wait a defined period to detect second press and if this occurs increment pressState to 2, else 1
Show your whole code, snippets are useless. Read how to use forum at top of every section