Error compiling for board Arduino Uno .

Hi, i was trying to make three led's and a buzzer be controlled by a motion sensor and a ir remote, but i was given this error message: Error compiling for board arduino uno.

My code:

#include <IRremote.h>
int RECV_PIN = 13; // Infrared receiving pin
int i=2;
IRrecv irrecv(RECV_PIN); // Create a class object used to receive class
decode_results results; // Create a decoding results class object
int greenLed = 4; // the number of the green LED
int yellowLed = 3; // the number of the yellow LED
int redLed = 2; // the number of the red LED
int sensorPin = 12; // the number of the motion sensor
int buzzerPin = 9; // the number of the buzzer 
float sinVal; // Define a variable to save sine value
int toneVal; // Define a variable to save sound 
void setup(){
 Serial.begin(9600); // Initialize the serial port and set the baud rate to 9600
 irrecv.enableIRIn(); // Start the receiver
 pinMode(greenLed, OUTPUT); // set green led into output mode
 pinMode(yellowLed, OUTPUT); // set yellow led into output mode
 pinMode(redLed, OUTPUT); // set red led into output mode
 pinMode(sensorPin, INPUT); // set the sensor into input mode
 pinMode(buzzerPin, OUTPUT); // Set Buzzer pin to output mode
}
void loop() {
 if (digitalRead(sensorPin) == HIGH) {
    Serial.println ("person in room");
     digitalWrite(greenLed, HIGH);
     //tone(buzzerPin, 1000);
    for (int x = 0; x < 360; x++) { // X from 0 degree->360 degree
         sinVal = sin(x * (PI / 180)); // Calculate the sine of x
         toneVal = 2000 + sinVal * 500; // Calculate sound frequency according to the sine of x
         tone(buzzerPin, toneVal); // Output sound frequency to buzzerPin
         delay(1);
    }
  } else {
    digitalWrite(greenLed, LOW);
    tone(buzzerPin, 0);
  }
 if (irrecv.decode(&results)) { // Waiting for decoding
 Serial.println(results.value, HEX); // Print out the decoded results in decimal form
 handleControl(results.value); // Handle the commands from remote control
 irrecv.resume(); // Receive the next value
 }

}
void handleControl(unsigned long value) {
 startLooking:
 switch (value) { // Handle the commands
 case 0xFF6897: // Receive the number '0'
 digitalWrite(greenLed, LOW); // Turn off green LED
 digitalWrite(yellowLed, LOW); // Turn off yellow LED
 digitalWrite(redLed, LOW); // Turn off red LED
  delay (1000);
 break;
 case 0xFF30CF: // Receive the number '1'
 digitalWrite(redLed, LOW); 
 digitalWrite(yellowLed, LOW); 
 digitalWrite(greenLed, HIGH); 
 delay (1000);
 break;
 case 0xFF18E7: // Receive the number '2'
 digitalWrite(redLed, LOW); // Turn off Buzzer
 digitalWrite(yellowLed, HIGH); // Turn off LED
 digitalWrite(greenLed, LOW); // Turn off LED  
  delay (1000);
 break;
 case 0xFF7A85: // Receive the number '3'
 digitalWrite(redLed, HIGH); // Turn off Buzzer
 digitalWrite(yellowLed, LOW); // Turn off LED
 digitalWrite(greenLed, LOW); // Turn off LED
  delay (1000);
 break;
 default:
for (;;) {
 digitalWrite(redLed, LOW); // Turn off Buzzer
 digitalWrite(yellowLed, HIGH); // Turn off LED
 digitalWrite(greenLed, LOW); // Turn off LED
 delay (400);
 digitalWrite (yellowLed,LOW);
 delay (400);

 case 0xFFE21D:
 break;
 
}
 break;
}
}

The error messages:

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries/IRremote/IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

Wouldn't it be a great idea if someone wrote down useful stuff like how to use code tags and put it in a sticky post at the top of every section of the forum?

1 Like

Yes, it would be. Do you not know how?

Or just read the "Washing instruction" for the forum.

I do know how. I read it in a sticky post at the top of one of the forum sections, around 8 years ago.

That's not an error message. It's just a message informing you that there are some error messages. Please post the error messages, all of them, in code tags.

I have made the suggested edits

1 Like

You have a conflict for one of the timer interrupt vectors.
I suggest you delete all references to "tone" in your sketch.

The IRremote library and the built-in 'tone()' function are both using the same timer interrupt.

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