0

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.

Basically:

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?)

Thanks.

asked Oct 10, 2015 at 22:56
2
  • 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, Commented Oct 10, 2015 at 23:03
  • A separate instance of what? Commented Oct 11, 2015 at 3:50

1 Answer 1

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

Nick Gammon
38.9k13 gold badges69 silver badges125 bronze badges
answered Oct 10, 2015 at 23:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.