Maker Pro
Arduino

How to Set Up Visual Studio Code

October 18, 2019 by Paul Lunn
Share
banner

Learn how to set up Microsoft’s Visual Studio Code and get more features as you work on your Arduino Projects!

While Arduino IDE is an easy-to-use and functional IDE a lot of us use for our Arduino projects, it may not contain all the features you want in an IDE. Microsoft’s Visual Studio (VS) Code is a free application that works on Windows, Mac OS, and Linux.

With a little bit of set up, VS Code can provide many useful features that are not available in Arduino IDE, such as syntax highlighting and intellisence. It can be configured to work with many other languages via its comprehensive extensions system. VS Code has many advantages over Microsoft’s main IDE, Visual Studio — it’s lightweight, easily adaptable, and is multiplatform which means that it also runs on Raspberry Pi’s Raspbian operating system.

In this tutorial, I will demonstrate how to set up VS Code for Arduino development within a Windows 10 environment.

Prerequisites

Before you begin, you need to install the Arduino IDE on your PC. VS Code uses the Arduino libraries in the background.

Installing VS Code

Once Arduino IDE is installed, VS Code can be downloaded for free. Once it’s downloaded, double click on the exe file to install. Clicking the exe file should display the following License Agreement:

VISUAL_STUDIO_SETUP_PL_MP_image3.jpg

Select “I accept the agreement” and click Next

VISUAL_STUDIO_SETUP_PL_MP_image2.jpg


You can change where VS Code is installed by clicking on the “Browse” button, but for most the default location will do. Click “Next”

VISUAL_STUDIO_SETUP_PL_MP_image5.jpg

I would recommend keeping the defaults for your start menu. Click “Next”.

VISUAL_STUDIO_SETUP_PL_MP_image4.jpg

The additional tasks dialog box allows you to associate VS Code with most programming file types like *.cpp,*.py or *.ino. This can be useful for quickly opening VS Code when you double click on a programming file. Make sure that “Add to Path” is selected. Click “Next”.

VISUAL_STUDIO_SETUP_PL_MP_image7.jpg

The above screenshot is just a summary of where VS Code will be installed. Click “Install” to begin.

VISUAL_STUDIO_SETUP_PL_MP_image6.jpg

If the installation is successful, you should now see the dialog box above.

When you run VS Code for the first time you may get a Security Alert pop up:

VISUAL_STUDIO_SETUP_PL_MP_image9.jpg

Select “Private networks, such as my home or work network” and then click “Allow Access”.

When you run VS Code for the first time, it will display this window:

VISUAL_STUDIO_SETUP_PL_MP_image8.jpg

Installing Extensions in VS Code

Out of the box, VS Code doesn’t support all languages, but there is a large number of extensions that add functionality to support additional features. To enable extensions, either click on the “Extension” icon on the left-hand margin of VS Code or use the shortcut “Ctrl-Shift-x”.

VISUAL_STUDIO_SETUP_PL_MP_image11.jpg

The Extension Icon

Installing the C++ Tools Extension

We need to install Microsoft’s C++ tools extension using the following steps:

  1. In the search bar type ms-vscode.cpptools
  2. Select the C/C++ search result
  3. Click on “Install” in the information window on the right
VISUAL_STUDIO_SETUP_PL_MP_image10.gif

VS Studio Extensions Marketplace

This tutorial has demonstrated how to install just one extension, but I would recommend browsing through Microsoft’s Extension Marketplace to see the vast amount of additional functionality that is available for VS Code.

Here are some of my recommendations for useful extensions available in the Marketplace:

  • Dracula – A popular dark theme that is available for many IDEs.
  • vscode-icons – Adds file icons to the explorer window.
  • Code Spell Checker – Checks all source code for spelling mistakes and suggests corrections.
  • Bracket Pair Colorizer – Makes your source code easier to debug by colorizing matching brackets.

Author

Avatar
Paul Lunn

Dr Paul Lunn is a Lecturer in IOT at Coventry University, UK. He enjoys tinkering with music, programming, Arduino, ESP32, and Raspberry Pi's

Related Content

Comments


You May Also Like