I'm relatively new to Arduino and I was trying to create a simple sketch that turns an LED light on when I press the up arrow on the remote and turns the LED light off when I press the down arrow. Right now, this is what I have:
#include <IRremote.h>
int RECEIVER_PIN = 12;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
IrReceiver.begin(RECEIVER_PIN);
}
void loop() {
// put your main code here, to run repeatedly:
if(IrReceiver.decode()){
if(IrReceiver.decodedIRData.command == 0x46) {
digitalWrite(LED_BUILTIN, HIGH);
} else if(IrReceiver.decodedIRData.command == 0x15) {
digitalWrite(LED_BUILTIN, LOW);
}
IrReceiver.resume();
}
}
Is there a better way to do this or am I on the right track. All feedback is welcomed and appreciated. Thanks!