So I made an arduino project with an ir receiver and remote that makes a led turn on and off and the same with a buzzer. But now i want to recognize just the code for that functions, and if another remote ir code is detected i want to set an alarm. How can i make that?
Any help appreciated. Thanks.
#include <IRremote.hpp>
#define rosu FBA45
IRrecv irrecv(11);
int RECV_PIN = 11;
int led = 9;
int buz = 12;
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
pinMode(buz, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(results.value );
switch (results.value ){
case 16489061:
digitalWrite(led, HIGH);
break;
case 16497221:
digitalWrite(led, LOW);
break;
case 16493141:
digitalWrite(buz, HIGH);
break;
case 16484981:
digitalWrite(buz, LOW);
break;
}
irrecv.resume();
}
delay(10);
}