I recently ordered an IR receiver and got it today. But when I had uploaded this sketch to it the led I was controlling with a remote control would just blink...
Is there something wrong with the sketch or is it the receiver or the led?
Here's the sketch.
#include <IRremote.h>
int RECV_PIN = 18;
int state = 0;
IRrecv irrecv(RECV_PIN);
int led = 17;
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);
irrecv.resume(); // Receive the next value
}
delay(100);
if (results.value == 0xE0E036C9) { //Button is pressed
if (state == 0) {
digitalWrite(led, HIGH);
state = 1;
} else {
digitalWrite(led, LOW);
state = 0;
}
}
}