Visual studio code as an arduino IDE

Do you like to work with the arduino IDE for writing code? Well, I don’t. Actually, I think it sort of sucks. But don’t worry, there are alternatives!  Today, I’d like to show you the one that I prefer: Visual studio code.

About Visual studio code

VSC is a new code editor from Microsoft and It has some advantages compared to it’s big brother Visual studio:

  • It runs on a lot of platforms, not just windows. If you prefer linux or mac, no problem, it’ll work.
  • It’s pretty light-weight: starting the application is very fast, unlike VS, which can take a long time to open from a cold-start.
  • There are lots of extensions for all sorts of operations
  • It supports a ton of languages, also done through extensions (so you could even add your own if you wanted to)
  • There is a free extension to work with arduino compatible devices (this is what we want!)

And compared to the arduino ide:

  • Better syntax highlighting: this can be a matter of taste, but I just don’t like the way that arduino IDE displays it’s code
  • Intellisense: never mind autocomplete, which the arduino ide doesn’t have. VSC provides similar smart completions as you can find in it’s bigger brother Visual studio.
  • Debugging features for devices that support hardware debugging.
  • proper project management.
  • It also starts up a lot faster.

frankly, the list goes on and on. It’s just a much better ide.

Setup your new IDE to support arduino development

Visual studio code: extensionsYou’ll need to install the following software to get started:

  • The original arduino IDE: yes, this is still a bit of a bummer, VSC still requires the original editor, primarily for it’s build chain and device management. Though, this means that any device working with your original editor, will also work with VSC without having to do anything extra.
  • Visual studio code of course.
  • And finally the arduino extension for VSC

The first 2 are easy enough: just download the software and run the installer.

The final step can perhaps use a little more explanation if you are not used to working with VSC. There are multiple ways you can go about this, but the easiest procedure that I have found is to:

  • Open visual studio code
  • go to the extensions view: click on the bottom icon in left toolbar or press ctrl+shift+x
  • search for the arduino plugin. Note: there are multiple versions from different people. It’s best to go with the one provided by Microsoft themselves.
  • Press the install button
  • reload your editor and you are ready.

Working with VSC

Visual studio code works primarily with commands. These depend on the extension that you are working with/want to use. In the case of the arduino extension, you have several commands at your disposal:

  • upload
  • verify
  • open/close the serial monitor
  • change the baut rate
  • select your board
  • manage available boards

To show the list of commands and select one, just press F1. If you type in the first letters of arduino, the list will filter and only show all the available arduino commands. From there, depending on the command that you select, a new dialog pops up or the command executes.

Trouble shooting

Are you getting this error after installing the extension?

Error: Cannot find the arduino installation path. Please specify the “arduino.path” in the User Settings

Probable causes:

  • You have not yet installed the original arduino IDE, so go ahead and install it now. Don’t forget to restart VSC or it wont see the changes.
  • You have installed it, but you specified a different directory. To solve this, in VSC, open the user settings: go to file/preferences/settings (or press Ctrl+comma), and find the line
    "arduino.path": "",

    Here, you can specify your custom path.

And that’s it. I hope you will enjoy this editor as much as I have.

2 thoughts on “Visual studio code as an arduino IDE

    • deebobo Post authorReply

      Ahh, Thanks for the heads up. That was linking to an article which is not yet ready for publication. I’ve temporarily removed the link until the post is ready. It was originally about debugging with the sodaq board. But recently, there are the new arduino iot boards which also use arm processors, so they should allow for debugging, that is, if the pins are exported on the boards (I’ve ordered some devices).

Leave a Reply

Your email address will not be published. Required fields are marked *