简体   繁体   中英

Error compiling board for Arduino/Genuino Uno [on hold]

I am still a beginner in arduino. I am building a Arduino Security System with a PIRsensor(motion sensor), a ultrasonic sensor, an LCD display, and an IR sensor. My error is:

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

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.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino/Genuino Uno.

If you want to see my full code, here it is:

#include <C:\Users\LENOVO USER\Documents\Arduino\libraries\U8glib\src\U8glib.h>
#include <LiquidCrystal.h>
#include <IRremote.h>     

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int trigPin = 10;
const int echoPin = 9;
const int buzzer = 6; //buzzer to arduino pin 6

int ledPin = 7;
int RECV_PIN = 13; 
int PIRsensor = 8;              // PIR sensor(motion sensor)
int state = LOW;             // by default, no motion detected
int val = 0;                 // variable to store the sensor status (value)
int countdown = 0;

float duration, distance;    //Ultrasonic sensor

IRrecv irrecv(RECV_PIN);     
decode_results results; 

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input

  lcd.begin(16, 2);
  irrecv.enableIRIn();  

  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  pinMode(ledPin, OUTPUT);
  pinMode(PIRsensor, INPUT);    // initialize sensor as an input

  Serial.begin(9600); 
}

void loop() {
  val = digitalRead(PIRsensor);   // read sensor value
  if(state == LOW){
    digitalWrite(ledPin, HIGH);
    digitalWrite(trigPin, HIGH);
    duration = pulseIn(echoPin, HIGH);
    distance = (duration/58);
    if(distance >= 182){
      for(int i=0; i==30; i++){
        countdown++;
        delay(1000); 
      }
      if (irrecv.decode(&results)){     
       int value = results.value;  
       Serial.println(value);         
       switch(value){        
         case -7177: //Keypad button "2"  
         countdown = 0;
         lcd.print("Welcome!");
         delay(30000);     
       }
       switch(value){        
         case 12495: //Keypad button "1"  
         if(countdown == 30){
          tone(buzzer, 1000); // Send 1KHz sound signal...   
         }
       }
       switch(value){        
         case 539: //Keypad button "3"  
         if(countdown == 30){
          tone(buzzer, 1000); // Send 1KHz sound signal...   
         }
       }
       switch(value){        
         case 25979: //Keypad button "4"  
         if(countdown == 30){
          tone(buzzer, 1000); // Send 1KHz sound signal...   
         }
       }
       irrecv.resume();
      }  
    }
  }
  else{
      digitalWrite(ledPin, LOW);
  }
} 

Please help and thank you!

The IRRemote library and the tone function use the same timer. You can't use them together.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM