Table of Contents
Configuring Visual Studio Code for Arduino development
Possible alternative to NetBeans for Arduino development.
See Microsoft's Arduino for Visual Studio Code extension (still in preview as of December 2019) for what might be a better approach.
Needed extension(s)
- Microsoft's C/C++ for Visual Studio Code
File associations
This may not be needed. But in case *.ino
files aren't automatically or fully interpreted by Code as a C++ file, I added:
// 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" },
to my global settings.json
file.
C++ settings
The settings file
Create a c_cpp_properties.json
file inside the project's .vscode
folder by doing one of the following
- Ctrl-Alt-P and C/Cpp: Edit configurations.
- Hover over the light bulb to the left of a green squiggly in an
#include
directive and select “Add include to path settings.” : details of what this produces/changes.
Add the following Arduino configuration to 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": "" } }
Note: the actual list of directories might change. Arduino Code Completion Directories is more likely to be up to date than the list here.
: TODO: Standard Arduino libraries (Serial, etc.) : TODO: Project-specific libraries : TODO: How to do the global configuration per user rather than per project?
Select configuration
Set the project to the Arduino configuration you added by Ctrl-Alt-P and C/Cpp: Select a configuration.
Build/Run commands
TODO