I can't find out why I am unable to compile this code. I am trying to build a model of a fan that can be controlled manually with an IR remote or be put to automatic where it reacts to the temperature it's reading, I don't have much time o figure out the issue so I am hoping you guys can help.
#include <IRremote.h>
int RECV_PIN = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define POWER 0x10EFD827
#define A 0x10EFF807
#define B 0x10EF7887
#define C 0x10EF58A7
#define UP 0x10EFA05F
#define DOWN 0x10EF00FF
#define LEFT 0x10EF10EF
#define RIGHT 0x10EF807F
#define SELECT 0x10EF20DF
#define tempPin A0
#define speakerPin 11
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25
#define NUMSAMPLES 5
#define BCOEFFICIENT 3950
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
void setup(void)
{
pinMode(12, OUTPUT);
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
analogReference(EXTERNAL);
irrecv.enableIRIn();
}
void loop(void) {
uint8_t i;
float average;
for (i = 0; i < NUMSAMPLES; i++) {
samples = analogRead(tempPin);
- delay(10);*
}
average = 0;
for (i = 0; i < NUMSAMPLES; i++) {
_ average += samples*;_
_}_
average /= NUMSAMPLES;
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
float temp;
temp = average / THERMISTORNOMINAL; // (R/Ro)
temp = log(temp); // ln(R/Ro)
temp /= BCOEFFICIENT; // 1/B * ln(R/Ro)
temp += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temp = 1.0 / temp; // Invert
temp -= 273.15; // convert to C
Serial.print("Temperature ");
Serial.print(temp);
Serial.println(" *C");
if (irrecv.decode(&results)) {
_ if (results.value == POWER) {_
_ Serial.println("POWER");_
_ digitalWrite(9, !digitalRead(9));_
_ }_
_ if (results.value == A) {_
_ Serial.println("A");_
_ analogWrite(3, 75);_
_ }_
_ if (results.value == B) {_
_ Serial.println("B");_
_ analogWrite(3, 150);_
_ }_
_ if (results.value == C) {_
_ Serial.println("C");_
_ analogWrite(3, 225);_
_ }_
_ if (results.value == SELECT) {_
_ if (temp > 40) {_
_ analogWrite(3, 255);_
_ tone(speakerPin, 2960);_
_ delay(1000);_
_ noTone(speakerPin);_
_ delay(1000);_
_ }_
_ else {_
_ analogWrite(3, (temp * 40));_
_ Serial.print("temp sensor: " );_
_ Serial.println(analogRead(0));_
_ Serial.print("fan Speed: ");_
_ Serial.println(analogRead(3));_
_ }_
_ }_
_}_
irrecv.resume(); {}
_}*_
error:
C:\Users\aless\AppData\Local\Temp\build05179632bbaab9693c1bb560cf38cfed.tmp/core\core.a(Tone.cpp.o): In function__vector_7':*</em> <em>*C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Tone.cpp:539: multiple definition of__vector_7'
libraries\Arduino-IRremote-master\IRremote.cpp.o:C:\Users\aless\Documents\Arduino\libraries\Arduino-IRremote-master/IRremote.cpp:131: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.