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)

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

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.

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