I'm trying my best attempt here after failing in Googling the answer, but here goes:

I'm trying to get a separate instance to start running in the background when a pin goes HIGH. How should I attempt this? PLEASE explain your answer, so that I can learn as well. I'm using an Arduino Uno R3 with a Commercial Ir RX-Tx.


Sensor -> Low -> Loop
Sensor -> High -> Start Other Event for 5 min -> Loop while Counting down to reset state.

My thoughts here are:
Do this via 555-timer OR get some functional coding (anyone maybe want to share here what solutions they have found?)


  • 1
    The answer can be summed up into one three word phrase: "Finite State Machine". A technique you should learn and learn well. Google it and marvel at the results now you know what to search for,
    – Majenko
    Oct 10, 2015 at 23:03
  • A separate instance of what?
    – Nick Gammon
    Oct 11, 2015 at 3:50

1 Answer 1


Arduino Uno has two interrupt pins: 2 and 3, and by hooking up the output of your IR, which goes from LOW to HIGH, it will trigger the function that you defined in the code.

For example this is a piece of code that runs when the pin 2 RISING:

void setup() {
    attachInterrupt(0, doSomething, RISING);

void loop() {

void doSomething() {
    //Do your stuff

Look here for further information link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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