problem with: IRrecv irrecv(RECV_PIN);

I can not speak English well. I’m sorry for my mistakes! :confused:

I used arduino UNO and Windows10 and latest version of the Arduino software.

i connected 3 led to pin 2,4,6 and install IR receiver sensor to pin 11 and a buzzer to pin 3.

i need to on and off LED with remote control and play song with buzzer.

My code is:

#include <IRremote.h>
int RECV_PIN = 11; // 
int output1 = 2;
int output2 = 4;
int output3 = 6;
int output4 = 10;
int buzzer = 3;
int itsONled[] = {0,0,0,0}
#define code1  47175 // 
#define code2  14535 // 
#define code3  25245 // 
#define code4  43095 // 
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
delay(1000);
  Serial.begin(9600);   // 
  irrecv.enableIRIn();  // 
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(output3, OUTPUT);
  pinMode(output4, OUTPUT);
}
void loop() {

  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) {
       case code1:
         if(itsONled[1] == 1) {        // 
            digitalWrite(output1, LOW);   // 
            itsONled[1] = 0;           // 
         } else {                      // 
             digitalWrite(output1, HIGH); // 
             itsONled[1] = 1;          // 
         }
          break; 
       case code2:
         if(itsONled[2] == 1) {
            digitalWrite(output2, LOW);
            itsONled[2] = 0;
         } else {
             digitalWrite(output2, HIGH);
             itsONled[2] = 1;
         }
          break;
       case code3:
         if(itsONled[3] == 1) {
            digitalWrite(output3, LOW);
            itsONled[3] = 0;
         } else {
             digitalWrite(output3, HIGH);
             itsONled[3] = 1;
         }
          break;          
        case code4:
            beep(20,50);
          break;       
    }
    Serial.println(value); // you can comment this line
    irrecv.resume(); // Receive the next value
  }
}
void beep(int fercancy , int delayms) {
  analogWrite(buzzer, fercancy);
  delay(delayms);
  analogWrite(buzzer,0); 
  delay(delayms);
}

and the error is:

IR:13: error: expected ',' or ';' before 'IRrecv'

 IRrecv irrecv(RECV_PIN);

 ^

C:\Users\mohammad\Desktop\IR\IR.ino: In function 'void setup()':

IR:26: error: 'irrecv' was not declared in this scope

   irrecv.enableIRIn();  // 

   ^

C:\Users\mohammad\Desktop\IR\IR.ino: In function 'void loop()':

IR:34: error: 'irrecv' was not declared in this scope

   if (irrecv.decode(&results)) {

       ^

exit status 1
expected ',' or ';' before 'IRrecv'

There may be other issues, but your first problem is that you are missing a semicolon:

int itsONled[] = {0,0,0,0}

should be

int itsONled[] = {0,0,0,0};

Thank you very much Solved Good luck :sunglasses:

i very try to listen to song of buzzer

help me please!

new code:

#include <IRremote.h>
int RECV_PIN = 11; // 
int output1 = 2;
int output2 = 4;
int output3 = 6;
int buzzer = 10;
int itsONled[] = {0,0,0,0};
#define code1  47175 // 
#define code2  14535 // 
#define code3  25245 // 
#define code4  43095 // 
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
  beep(20,50);
delay(1000);
  Serial.begin(9600);   // 
  irrecv.enableIRIn();  // 
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(output3, OUTPUT);
  pinMode(buzzer, OUTPUT);
}
void loop() {

  if (irrecv.decode(&results)) {
    unsigned int value = results.value;
    switch(value) {
       case code1:
         if(itsONled[1] == 1) {
            digitalWrite(output1, LOW);
            itsONled[1] = 0;
         } else { 
             digitalWrite(output1, HIGH);
             itsONled[1] = 1;
         }
          break; 
       case code2:
         if(itsONled[2] == 1) {
            digitalWrite(output2, LOW);
            itsONled[2] = 0;
         } else {
             digitalWrite(output2, HIGH);
             itsONled[2] = 1;
         }
          break;
       case code3:
         if(itsONled[3] == 1) {
            digitalWrite(output3, LOW);
            itsONled[3] = 0;
         } else {
             digitalWrite(output3, HIGH);
             itsONled[3] = 1;
         }
          break;          
        case code4:
            beep(20,50);
          break;       
    }
    Serial.println(value);
    irrecv.resume();
  }
}
void beep(int fercancy , int delayms) {
  analogWrite(buzzer, fercancy);
  delay(delayms);
  analogWrite(buzzer,0); 
  delay(delayms);
}