I am new to arduino programming and am working on a self made project from the little coding and messing around with sensors and tutorials I have done. In this program, I have an ultrasonic sensor which detects if something is in a certain range to then sound off a buzzer and turn on an led. When nothing is in range, no buzz, and a different led is active. I also have attached an ir module to make this device remote controlled so it can be activated or in standby mode with one of the led's just blinking to let you know the alarm wont sound.
Here is my
#include <IRremote.h>
#define trigPin 12
#define echoPin 13
int Buzzer = 8; // Connect buzzer pin to 8
int ledarmed = 6;//Connect LEd armed pin to 6
int ledunarmed = 5;//led unaarmed pin to 5
int duration, distance; //to measure the distance and time taken
const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin (9600);
//Define the output and input objects(devices)
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(Buzzer, OUTPUT);
pinMode(ledarmed, OUTPUT);
pinMode(ledunarmed, OUTPUT);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)){
switch(results.value){
case 0xFF629D: //Keypad button vol+
int var = 0;
while (var == 0){
digitalWrite(ledunarmed,HIGH);
delay(500);
digitalWrite(ledunarmed,LOW);
delay(500);
}
}
switch(results.value){
case 0xFF02FD: //Keypad button play
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
//when distance is greater than or equal to 200 OR less than or equal to 0,the buzzer and LED are off
if (distance >= 30 || distance <= 0)
{
Serial.println("no object detected");
noTone(Buzzer);
digitalWrite(ledarmed,LOW);
digitalWrite(ledunarmed,HIGH);
}
else {
Serial.println("object detected \n");
Serial.print("distance= ");
Serial.print(distance); //prints the distance if it is between the range 0 to 200
tone(Buzzer, 800); // Send 1KHz sound signal...
delay(150); // ...for 1 sec
noTone(Buzzer);
digitalWrite(ledarmed,HIGH);
digitalWrite(ledunarmed,LOW);
}
}
irrecv.resume();
}
}
And these are the errors I have after troubleshooting my best:
Using library irremote_2_2_3 at version 2.2.3 in folder: /home/builder/opt/libraries/latest/irremote_2_2_3
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
/tmp/261951209/build/libraries/irremote_2_2_3/IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Any help is greatly appreciated!!