为什么要用VScode
代替Arduino
?因为它是最好的进行arduino开发的利器,支持许多Arduino IDE
所没有的功能,其Arduino
插件由微软开发,十分稳定。支持代码高亮,代码补全,转到定义,文件跳转等,有利于提高敲代码速度以及查看源码或者库文件。而且VScode
可以跨平台使用,Windows
,MAC
,Linux
都支持。而且没有vs
那样臃肿,其他比较好的c语言IDE如Clion(arduino插件由个人开发,相比vs系列,用户较少)的支持都不太好。
安装插件
步骤 1: 左键单击左下角齿轮设置按钮
步骤 2: 中左键单击菜单中拓展
步骤 3: 在搜索框输入arduino并安装(还需要安装 C/C++ 插件)
修改VScode设置
步骤 1: 左键单击左下角齿轮设置按钮
步骤 2: 点击"设置 "
步骤 3: 在"设置 "中左键单击右上角“打开json设置”按钮
步骤 4: 添加下方内容至括号中
1 2 3 4 5 6 7
| "arduino.path": "C:/Program Files (x86)/Arduino", "C_Cpp.intelliSenseEngine": "Tag Parser", "editor.insertSpaces": true, "files.autoGuessEncoding": true, "arduino.logLevel": "info", "explorer.confirmDelete": false, "editor.detectIndentation": false,
|
我的完整配置:
1 2 3 4 5 6 7 8 9 10 11 12
| { "git.path": "D:/mypro/PortableGit/bin/git.exe", "workbench.colorTheme": "Default Light+", "editor.tabCompletion": "on", "arduino.path": "C:/Program Files (x86)/Arduino", "C_Cpp.intelliSenseEngine": "Tag Parser", "editor.insertSpaces": true, "files.autoGuessEncoding": true, "arduino.logLevel": "info", "explorer.confirmDelete": false, "editor.detectIndentation": false, }
|
如此便可使用代码补全了
修改Arduino项目VScode配置文件
目的是让VScode识别Arduino项目
参照下方添加/修改项目根目录.vscode/C_cpp_properties.json
文件,请注意使用对应安装目录、我的文档arduino库目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| { "configurations": [ { "name": "Win32", "includePath": [ "C:/Program Files (x86)/Arduino/libraries", "C:/Program Files (x86)/Arduino/hardware/arduino/avr/**", "C:/Program Files (x86)/Arduino/hardware/tools/avr/avr/include", "C:/Program Files (x86)/Arduino/hardware/tools/avr/lib/gcc/avr/7.3.0/include", "C:/Program Files (x86)/Arduino/hardware/tools/avr/lib/gcc/avr/7.3.0/include-fixed", "C:/Program Files (x86)/Arduino/tools/**" ], "forcedInclude": [ "C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ "C:/Program Files (x86)/Arduino/libraries" ] }, "intelliSenseMode": "msvc-x64", "defines": [ "USBCON" ] } ], "version": 4 }
|
参考资料