看了博文1 博文2,知道了VSCode安装Arduino插件可以用来开发Arduino项目,但是实际使用时提示头文件未包含,显然是设置问题。#include errors detected. Please update your includePath.
百度没有搜索到相关的中文资料,搜到英文的资料,这里记录一下。
文件关联设置
设置文件 settings.json
添加以下脚本
// Files
// Configure file associations to languages (e.g. "*.extension": "html").
// These have precedence over the default associations of the languages
// installed.
"files.associations": {
"*.ino": "cpp"
},
设置头文件路径
在项目
.vscode 文件夹中 创建c_cpp_properties.json
文件,并添加相关头文件路径信息。{
"name": "Arduino",
"includePath": [
"{path-to-arduino}/hardware/arduino/avr/cores/arduino/",
"{path-to-arduino}/hardware/arduino/avr/libraries/EEPROM/",
"{path-to-arduino}/hardware/arduino/avr/libraries/SPI/",
"{path-to-arduino}/hardware/arduino/avr/libraries/SoftwareSerial/",
"{path-to-arduino}/hardware/arduino/avr/libraries/Wire/",
"{path-to-arduino}/hardware/tools/avr/avr/include/",
"{path-to-arduino}/hardware/tools/avr/avr/include/avr/",
"{path-to-arduino}/hardware/tools/avr/avr/include/compat/",
"{path-to-arduino}/hardware/tools/avr/avr/include/util/",
"{path-to-arduino}/hardware/tools/avr/lib/gcc/avr/4.*.*/include/",
"{path-to-arduino}/hardware/tools/avr/lib/gcc/avr/4.*.*/include-fixed/"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
【嵌入式开发|使用Visual Studio Code开发Arduino相关配置】