|
本帖最后由 element115mc 于 2020-12-31 08:33 编辑
第一次玩arduino,想做个测距仪,预期效果:开屏显示“Made by element115mc”,隔2秒刷新一次距离。
结果程序怎么也写不进去,但是随便挑一个示例写进去都行
系统:Windows10企业版
Arduino版本:1.8.9
开发板:UNO
要搭配的外设: LCD1602A、US-025超声波模块(可兼容HC-SR04)
CH340驱动:已安装
错误信息:
Arduino:1.8.9 (Windows 10), 开发板:"Arduino/Genuino Uno"
D:\arduino\arduino-builder -dump-prefs -logger=machine -hardware D:\arduino\hardware -tools D:\arduino\tools-builder -tools D:\arduino\hardware\tools\avr -built-in-libraries D:\arduino\libraries -libraries d:\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=1A86_7523 -ide-version=10809 -build-path C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_927525 -warnings=all -build-cache C:\Users\ADMINI~1\AppData\Local\Temp\arduino_cache_401094 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=D:\arduino\hardware\tools\avr -verbose D:\desktop\sketch_dec30a\sketch_dec30a.ino
D:\arduino\arduino-builder -compile -logger=machine -hardware D:\arduino\hardware -tools D:\arduino\tools-builder -tools D:\arduino\hardware\tools\avr -built-in-libraries D:\arduino\libraries -libraries d:\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=1A86_7523 -ide-version=10809 -build-path C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_927525 -warnings=all -build-cache C:\Users\ADMINI~1\AppData\Local\Temp\arduino_cache_401094 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.2.1.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-5.4.0-atmel3.6.1-arduino2.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino14.path=D:\arduino\hardware\tools\avr -verbose D:\desktop\sketch_dec30a\sketch_dec30a.ino
Using board 'uno' from platform in folder: D:\arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: D:\arduino\hardware\arduino\avr
Detecting libraries used...
"D:\\arduino\\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=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\sketch\\sketch_dec30a.ino.cpp" -o nul
"D:\\arduino\\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=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\arduino\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\arduino\\libraries\\LiquidCrystal\\src" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\sketch\\sketch_dec30a.ino.cpp" -o nul
"D:\\arduino\\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=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\arduino\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\arduino\\libraries\\LiquidCrystal\\src" "D:\\arduino\\libraries\\LiquidCrystal\\src\\LiquidCrystal.cpp" -o nul
Generating function prototypes...
"D:\\arduino\\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=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\arduino\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\arduino\\libraries\\LiquidCrystal\\src" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\sketch\\sketch_dec30a.ino.cpp" -o "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"D:\\arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\preproc\\ctags_target_for_gcc_minus_e.cpp"
正在编译项目...
"D:\\arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\arduino\\hardware\\arduino\\avr\\variants\\standard" "-ID:\\arduino\\libraries\\LiquidCrystal\\src" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\sketch\\sketch_dec30a.ino.cpp" -o "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\arduino_build_927525\\sketch\\sketch_dec30a.ino.cpp.o"
D:\desktop\sketch_dec30a\sketch_dec30a.ino:1:27: warning: extra tokens at end of #include directive
#include <LiquidCrystal.h>;
^
In file included from C:\Users\ADMINI~1\AppData\Local\Temp\arduino_build_927525\sketch\sketch_dec30a.ino.cpp:1:0:
D:\desktop\sketch_dec30a\sketch_dec30a.ino: In function 'void loop()':
D:\arduino\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: expected unqualified-id before numeric constant
#define LOW 0x0
^
D:\desktop\sketch_dec30a\sketch_dec30a.ino:25:21: note: in expansion of macro 'LOW'
digitalWrite(Trig.LOW);
^
使用 1.0.7 版本的库 LiquidCrystal 在文件夹: D:\arduino\libraries\LiquidCrystal
exit status 1
为开发板 Arduino/Genuino Uno 编译时出错。
源代码:
- #include <LiquidCrystal.h>;
- #define LM35 A0;
- #define Trig 8
- #define Echo 9
- float cm;
- LiquidCrystal lcd(12,11,5,4,3,2);
- int val = 0;
- float Temp = 0;
- void setup() {
- lcd.begin(16,2);
- lcd.setCursor(0,0);
- lcd.print("Made by");
- lcd.setCursor(0,1);
- lcd.print("element115mc");
- delay(2000);
- lcd.clear();
- pinMode(Trig,OUTPUT);
- pinMode(Echo,INPUT);
- }
-
- void loop() {
- digitalWrite(Trig.LOW);
- delayMicroseconds(2);
- digitalWrite(Trig,HIGH);
- delayMicroseconds(10);
- digitalWrite(Trig,LOW);
- Temp = float(pulseIn(Echo,HIGH));
- cm = (Temp*17)/1000;
- lcd.setCursor(0,0);
- lcd.print(cm);
- lcd.setCursor(0,1);
- lcd.print("centmeter");
- delay(2000);
-
- }
复制代码
|
|