Where am I wrong?Debounce related question[SOLVED]
hi all, i'm having problem that's driving me crazy! i take debounce code arduino examples sketch, , add couple of check more: code: [select] void loop() { int reading = digitalread(buttonpin); // if switch changed, due noise or pressing: if (reading != lastbuttonstate) { // reset debouncing timer lastdebouncetime = millis(); } if ((millis() - lastdebouncetime) > debouncedelay) { // whatever reading at, it's been there longer // debounce delay, take actual current state: buttonstate = reading; [glow] if(buttonstate == high) { if(toggle == high) toggle = low; else toggle = high; }[/glow] } // set led using state of toggle: [glow]digitalwrite(ledpin, toggle); [/glow] // save reading. next time through loop, // it'll lastbuttonstate: lastbuttonstate = reading; } the highlighted part mine, need behaviour: - button pressed ...