Use Visual Studio Code for Arduino

Mark Zachmann
Feb 19, 2018 · 5 min read

VSCode has an Arduino plugin available in preview. Use it. Put your Arduino desktop application in cold-storage. Comparing the two is like comparing a beaver with a 2 ton backhoe.

Image for post
Image for post
Visual Studio Code with an Arduino App
  1. Lots of useful key-stroke sequences, fully programmable.
  2. Integrated with Git.
  3. Intellisense that works.
  4. Jump to definition and mouseover display in-line help.
  5. Hugely useful on-screen click objects.
  6. Full support for folder trees.
  7. Plugin support.
  8. Seriously have you used the Arduino IDE? Who needs a list?
  1. For now you can’t type into the serial monitor window. That’s not cool. — Update: the latest version of the Arduino plugin now lets you send a string to the serial monitor. It’s clumsier than a modem program but very usable.

Getting Started

  • A working version of Arduino desktop that can build.
  • Visual Studio Code with Microsoft’s Arduino Extension installed. Install it from the Extensions tab (below the debug button on the far left).
Image for post
Image for post
The Arduino Extension (per-workspace enabled)

Assume you have a working project you want to convert to VSCode. Just

  1. Run VSCode and open the project folder.
  2. (optional but recommended) Use the source control tab to initialize a new git repository and check in your existing code.
  3. From the command palette run: Arduino: Initialize
  4. Edit the project files (see below) for any workspace-specific project variables (such as includes).

Taking Advantage of Visual Studio Code with Arduino

Once the Arduino extension is enabled for your project there are some tricks to make life better.

Strangely, arduino doesn’t support subfolders (it won’t automatically build and link them) unless they begin with a src subfolder root. See here: Recursive src Folder Discussion

Take a look at the picture at the start and make sure your source tree looks like:

--- src
------- FolderA
------- FolderB

Depending on how the plugin works today, you may not get an output option defined in the arduino.json settings file. Add this line just above the closing brace:

,"output": "build"

Here I’ve defined the output folder as build. It will create a build folder in the project root where the caching of all the Arduino stuff takes place. That has two advantages:

  • It will decrease build time substantially. Strangely if you don’t set output you don’t get caching.
  • Since Arduino is kind of bad at figuring out caches you can just delete the entire build folder contents to force a clean build.

Warning: from what I can tell putting the build folder inside your project tree sometimes causes issues. This is documented in the Arduino source. A better solution is to build in a folder outside of the project.

In typical new-age dumb software fashion there are lots of useful buttons on the bottom of the display that aren’t obvious but that you should totally learn to use.

Image for post
Image for post
The bottom stripe on Visual Studio Code showing two mouse-over tooltips.

Mouse over them and you’ll see all sorts of easy ways to change stuff.

Visual Studio Code Settings for Arduino

The meat of the matter. There are four project settings files related to visual studio code and to Arduino. They can be confusing and you can often change them in more than one place. I’m going to skip tasks.json but discuss the rest.

This will create a .vscode folder if there isn’t one. It will also add the current Arduino settings to a file named arduino.json placed into the .vscode folder.

The following discussion refers to files found in the .vscode folder in your project. Add them there if they don’t exist.

This contains Arduino-specific settings. Most are set when you make changes with buttons and the Command Palette. Only the “output” folder did I notice as needing manual maintenance.

Add to your arduino.json (see above):

”output”: “build”

This file determines what gets linked and how intellisense finds files. Builds will still work but your mouseover helps and go-to-definitions and etc will be wrong if this is wrong.

"configurations": [
"name": "Win32",
"includePath": [
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"intelliSenseMode": "msvc-x64"
"version": 3

My c_cpp_properties.json starts with workspaceRoot and the next three lines point at the standard ESP32 libraries (since this projects uses an ESP32) and then generically points at the default sketch library set and the local arduino packages. C:/Sr/Sketch is my Arduino Sketch folder.

Note the Local Appdata folder. This is the standard Windows location (with my name Mark). In many systems this folder is hidden or marked ‘system’ and in either case you won’t see it in a browse tree. You can type cd %appdata% to go the remote appdata folder.

This is the normal VSCode settings file. You can change it in workspace settings (File / Preferences / Settings and then the Workspace Settings tab) or you can use an editor.

User Settings for Arduino

“arduino.enableUSBDetection”: false

Turn off enableUSBDetection or it will (at least in my case) constantly nag you to change your board to what it thinks it reads from USB. If you mistakenly click Ok it will delete your current settings and use that incorrect driver to boot (sigh). So, turn it off.

Workspace Settings for Arduino

I set the external boards URL for the ESP32 supported boards:



It’s not obvious how to get rid of a library (or two) and sometimes arduino seems to choke. The easiest thing to do is to delete most of the contents of the arduino appdata folder (look in %appdata%\..\local for an Arduino15 folder). One of these files is the settings. Keep that.

After you delete the rest of the files all the installed board libraries will disappear and you get to start over (usually a good thing).

Home Wireless

Home automation in the wireless IOT era

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store