Basic hardware debouncing 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&amp;list=PLA567CE235D39FA84&amp;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:-

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...
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()
{
  Serial.begin(9600);
  pinMode(sp, INPUT);
  pinMode(lp,OUTPUT);
}

void loop()
{

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

   else {
     lastbutton=digitalRead(sp);
      }
   Serial.println(ledon);
   digitalWrite(lp,ledon);

  
        
     }