Articles

Polling vs. Interrupts – An Introduction To Microcontrollers – PyroEDU

May 30, 2019

You Might Also Like

2 Comments

  • Reply SeventyV May 30, 2019 at 4:41 pm

    The change to "void setup" below allows the code to work on Arduino UNO using the onboard LED and Digital pin 2 as the switch. The only part needed is a switch between between digital pin 2 and ground. As Dave Sparks pointed out there is no debounce code so don't expect reliable switching operation.
    ——————————————————————-
    void setup(){
    //setup digital pin 13 as output
    pinMode(13, OUTPUT);
    //enable pullups on pin 2
    pinMode(2, INPUT_PULLUP);
    //Attach Interrupt module
    attachInterrupt(digitalPinToInterrupt(2), blink, RISING);
    //attachInterrupt(2, blink, RISING); //doesnt work with UNO
    }

  • Reply Chaplain Dave Sparks May 30, 2019 at 4:41 pm

    Where is the button debounce being done?

  • Leave a Reply