Little project with ir receiver and remote

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() {
 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);
      case 16497221:
      digitalWrite(led, LOW);
      case 16493141:
      digitalWrite(buz, HIGH);
      case 16484981:
      digitalWrite(buz, LOW);
1 Like

Post your code and we can show you the point where you can add your alarm code.

Before you post your code, read the forum guide. We can tell from only the title you gave your topic that you did not read the guide yet. Thankyou for your cooperation.

Thanks, i read it and i added the code.

1 Like

Thanks for posting the code correctly and correcting the topic title!

Inside the switch-case statement, after the last break;, put

  //Code for your alarm here
1 Like

Thank you so much, I'm gonna try this right now.

Apologies, I made an error and corrected my previous post. I have used so many computer languages in my life that I sometimes get them confused!

1 Like

Now its working, thanks for the help!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.