====== Configuring Visual Studio Code for Arduino development ====== Possible alternative to NetBeans for Arduino development. See Microsoft's [[https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino|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 [[https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools|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." FIXME: 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|Arduino Code Completion Directories]] is more likely to be up to date than the list here. FIXME: TODO: Standard Arduino libraries (Serial, etc.) FIXME: TODO: Project-specific libraries FIXME: 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 ===== FIXME TODO ===== Resources ===== * [[https://code.visualstudio.com/docs/languages/cpp|C/C++ for VS Code (Preview)]] * [[https://code.visualstudio.com/updates/vMarch#_editor|Visual Studio Code March 2016 1.0 release notes]]