I was watching Jeremy Blum's Arduino tutorial series, and he explained the need for debouncing in a simple circuit involving a pushbutton. Pressing the button once should mean the led stays on, and pushing the button again should mean the led should stay off, and so on.

He implemented hardware debouncing on this circuit: using an RC circuit along with an inverting Schmitt trigger.

https://www.youtube.com/watch?v=CRJUdf5TTQQ&list=PLA567CE235D39FA84&index=10 2:45-8:45.

However, the circuit isn't performing as expected, when I implemented the denbuncing. Its behaving as if the debouncing has no effect:- enter image description here

If anyone wants to see the simulation:- https://www.tinkercad.com/things/dniOQmnxJPY

Where exactly have I gone wrong? I have checked all the connections multiple times, it seems to be what Jeremy blum had in his video...

  • I changed the "debugging" in the title to "debouncing", because obviously you meant that. Also "hardware debugging" has a specific meaning with microcontrollers. That would only lead to confusion
    – chrisl
    Apr 26, 2021 at 16:32
  • 1
    When following the link for your simulation I am required to log in. Maybe you need to make the simulation public somehow, before anyone can see it.
    – chrisl
    Apr 26, 2021 at 16:36
  • I see, thanks for letting me know
    – satan 29
    Apr 26, 2021 at 16:40
  • @chrisl I have made it public now.
    – satan 29
    Apr 26, 2021 at 16:42
  • 1
    @satan29 What SBF meant is the following: The 74HC14 has 2 rows of pins you have put it on one side of the breadboard. That means, that the first on the left pin row of the chip and the first on the right row are connection. Similar for all other pins. Such chips need to be placed right in the middle of the breadboard, so that there is no electrical connection between the sides. That is your problem.
    – chrisl
    Apr 26, 2021 at 19:45

1 Answer 1


You did not change the lastbutton, but you compared it to HIGH. Change your code to the one below.

You can more easily avoid such mistakes, if you put spaces around operators.

//sp is switchpin, lp is ledpin

int sp=2; //interrupt enabled pin (interrupt 0)
bool ledon=LOW;
bool lastbutton=LOW;
int lp=9;
void setup()
  pinMode(sp, INPUT);

void loop()

   if (digitalRead(sp)==HIGH && lastbutton==LOW){
      lastbutton = HIGH; // previously here was lastbutton==HIGH;

   else {

  • Ah yes. Thanks! The debouncing works perfectly now. But for some weird reason the LED turns on at the start of the simulation....without pressing the switch or anything....any idea why?
    – satan 29
    Apr 27, 2021 at 5:24
  • 1
    I think because of your filter. It takes some time to charge up that capacitor, that means your Inverting Schmitt Trigger input starts low, and at the first run of the loop, your pin 2 starts high. If you put a small delay in your setup(), the LED starts off.
    – Kerbolosh
    Apr 27, 2021 at 6:08
  • indeed. delay(100) fixes this . Thanks a lot!
    – satan 29
    Apr 27, 2021 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.