Here's what I want to do:
- Wait for a particular IR remote signal (e.g.- button 5 on remote)
- If no signal is detected within 60s, turn on LED for 30s, then turn everything off (if that's possible in arduino)
This is the code I have now. It turns on pin 9 when I press "5" on my remote.
/*
Some Sample code of how to use your IR remote
* Lets get started:
The IR sensor's pins are attached to Arduino as so:
Pin 1 to Vout (pin 11 on Arduino)
Pin 2 to GND
Pin 3 to Vcc (+5v from Arduino)
*/
#include <IRremote.h>
int IRpin = 11; // pin for the IR sensor
int LED = 9; // LED pin
IRrecv irrecv(IRpin);
decode_results results;
boolean LEDon = false; // initializing LEDon as true
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(LED, OUTPUT);
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // Receive the next value
}
if (results.value == 0xFF38C7) // change zero to your IR remote button number
{
if (LEDon == false) // is LEDon equal to true?
{
LEDon = true;
digitalWrite(LED, HIGH);
delay(100); // keeps the transistion smooth
}
else
{
LEDon = false;
digitalWrite(LED, LOW);
delay(100);
}
}
}
My goal is to start the code in case IR remote is out of range. Can't think of an algorithm for that without thinking about running something in parallel. So, it's like this: we got IR signal? Great! Let remote control take over. No IR signal within 60s? Time to run that contingency code.