Hello, Could anyone tell me how to solve this problem I'm having.
I've been using my arduino with the IR remote control libraries.
mapping the function of some remote control keys.
to hopefully use it to control some relays.
I managed to get an LED to turn on using this code:
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
const int led = 7;
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(led, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if (results.value == 0xC03FE817) { // Power Button
digitalWrite(led, HIGH);
}
else if (results.value == 0xC03F6897) {
digitalWrite(led,LOW);
}
irrecv.resume();
}
}
I can get the led to turn off but its using a different button on the remote. My question is how do I use the same button to turn the led either on or off?
I've tried a few different ways but none of them seem to work. My guess would be I need to store some variables as an boolean but I'm unsure how to implement to this.
Thank you very much.