使用IRremote库运行代码时发生编译错误

时间:2020-06-20 13:57:59

标签: arduino infrared arduino-c++

我想使用IRremote库制作一个程序,该库使用rawlen对象的decode_results属性获取信号的长度以及5v / 0v信号的长度

目标是打印rawbuf值是串行监视器。

这是整个代码:

#include <IRremote.h>

int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;


void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
}


void dump(decode_results *results) {
  int count = results->rawlen;
  Serial.println("Signal recu !");
  Serial.print("Longueur du signal (");
  Serial.print(count, DEC);
  Serial.println("):");

  for(int i = 0; i < count; i++) {
    if((i%2) == 1) {
      Serial.println(results->rawbuf[i]*USECPERTICK, DEC);
    }
    else {
      Serial.println(-(int)results->rawbuf[i]*USECPERTICK, DEC);
    }
  }
}


void loop() {
  if(irrecv.decode(&results)) {
    dump(&results);
    irrecv.resume();
  }
}

当我运行它时,我会在编译器中得到它:

Arduino : 1.8.12 (Mac OS X), Carte : "Arduino Uno"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/briceamram/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10812 -build-path /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314 -warnings=none -build-cache /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_cache_657404 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/briceamram/Documents/Arduino/allume_led_pour_0/allume_led_pour_0.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/briceamram/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10812 -build-path /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314 -warnings=none -build-cache /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_cache_657404 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/briceamram/Documents/Arduino/allume_led_pour_0/allume_led_pour_0.ino
Using board 'uno' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/sketch/allume_led_pour_0.ino.cpp -o /dev/null
Alternatives for IRremote.h: [IRremote]
ResolveLibrary(IRremote.h)
  -> candidates: [IRremote]
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/briceamram/Documents/Arduino/libraries/IRremote /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/sketch/allume_led_pour_0.ino.cpp -o /dev/null
Using cached library dependencies for file: /Users/briceamram/Documents/Arduino/libraries/IRremote/IRremote.cpp
Generating function prototypes...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/briceamram/Documents/Arduino/libraries/IRremote /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/sketch/allume_led_pour_0.ino.cpp -o /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/preproc/ctags_target_for_gcc_minus_e.cpp
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/preproc/ctags_target_for_gcc_minus_e.cpp
Compilation du croquis...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10812 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/briceamram/Documents/Arduino/libraries/IRremote /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/sketch/allume_led_pour_0.ino.cpp -o /var/folders/z3/fzx06_6x2wvc0bj19lymf7x00000gp/T/arduino_build_24314/sketch/allume_led_pour_0.ino.cpp.o
get_rawbuf:16:11: error: variable or field 'dump' declared void
 void dump(decode_results *results) {
           ^~~~~~~~~~~~~~
get_rawbuf:16:11: error: 'decode_results' was not declared in this scope
get_rawbuf:16:27: error: 'results' was not declared in this scope
 void dump(decode_results *results) {
                           ^~~~~~~
Utilisation de la bibliothèque IRremote prise dans le dossier : /Users/briceamram/Documents/Arduino/libraries/IRremote (legacy)
exit status 1
variable or field 'dump' declared void

你知道是什么问题吗?

谢谢

0 个答案:

没有答案