I'm trying to get an IR receiver input to turn a led on and off, My code is this (I have a MEGA 2560):
#include "IRremote.h"
int Led = 13;
int receiver = 12;
IRrecv irrecv(receiver);
decode_results results;
void setup() {
irrecv.enableIRIn();
pinMode (Led, OUTPUT);
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 0xFFA857: // VOL+ button pressed
digitalWrite (Led, HIGH);
break;
case 0xFF629D: // VOL- button pressed
digitalWrite (Led, LOW);
break;
}
irrecv.resume(); // receive the next value
}
}/* --end main loop -- */
It seems that the IR receiver works and the led doesn't turn on when supposed to (Both components are fine) I don't know what the problem is. I also included a very low Fritzing of my build