There's an Arduino in your VS Code...

Sign in to queue

Description

The final post for the VS Code Theme week comes from the man, the myth, the legend in his own mind :) Fabien Royer.

Given it's Hardware Friday and VS Code week, how can we mesh these two together?

Maybe a little Arduino development with VS Code? Yeah, that's the ticket!

fabienroyer/VisualStudioCodeArduino

arduino upload

Using Visual Studio Code as an Arduino IDE

The arduino IDE is great to get a project configured and started quickly, but its built-in code editor leaves a lot to be desired. Even though an external editor can be used instead, the experience could still be improved upon. With the release of Visual Studio Code for Linux, Windows and Mac OS, there's an opportunity to make coding for arduino enjoyable while preserving the ability to compile and upload sketches directly from the editor. Keep in mind that you'll still need to use the arduino environment at least once to manage a project's imported libraries, target boards settings, serial port settings, etc.

The following document describes how this can be accomplished in three easy steps.

1. Making the 'arduino' executable available

By default, the arduino environment on Linux is not visible outside of its installation directory and needs to be exposed as a command for Visual Studio Code to invoke it when compiling and uploading arduino sketches.

Skip this step if the arduino environment is already available from anywhere.

The following step creates a symbolic link to the arduino environment so that it can be accessed from anywhere. It is assumed that the arduino environment was installed in the user's /home directory, such as:

...

2. Copy the ino folder to your local Visual Studio Code extension folder

The ino folder in this repository provides Visual Studio Code with the arduino keyword definitions needed for syntax highlighting. It also specifies that .ino files should be handled as C/C++ files.

The repository contains the following files & folders:

...

3. Adding the Visual Studio Code Task Runners supporting arduino

From Visual Studio Code, do the following:

  1. Open the File menu and select Open Folder....
  2. Navigate to the folder containing your arduino projects.
  3. Bring up the command palette with Ctrl+Shift+P.
  4. Type task in the command window.
  5. Select Configure Task Runner. This will create a hidden folder named .vscode at the root of the arduino projects folder selected in step 2.

...

4. Usage

  1. Open a .ino project file.
  2. Bring up the command palette with Ctrl+Shift+P
  3. Type task in the command window.
  4. Select Run Task

...

terminal

Note

This procedure has been validated to work with the following configuration:

  • Ubuntu Linux 14.04 LTS
  • arduino 1.6.4
  • Visual Studio Code 0.9.x

 

[Click through for the repo]



The Discussion

  • User profile image
    FabienRoyer

    Wow, Greg! I'm humbled.

    Cheers,

    -Fabien.

  • User profile image
    gduncan411
  • User profile image
    nobodykid23

    wow, i'm impressed. I used to work with Arduino

    also, is this available in Windows? I'm currently having the latest version of Code

  • User profile image
    bradygaster

    Wondering if there's a way to make this work for the Particle Photon, too. Awesome work, Fabien & Greg!

  • User profile image
    FabienRoyer

    @nobodykid23: It works as-is under Windows as well.

  • User profile image
    FabienRoyer

    @bradygaster: Thanks Brady :) The Particle Photon already has its own Atom-based IDE, similar to VS Code and features very similar commands.

    If you still wanted to use VS Code with the Particle boards, you could integrate them using the Particle's CLI interface

    I hope this helps.

    -Fabien.

  • User profile image
    Betteronly

    sorry,i can not use the vscode for arduino.
    i use the Win10, arduino 1.6.7,and vsCode as 0.10.1.

    i have read and done all the thinke of [https://github.com/fabienroyer/VisualStudioCodeArduino],
    but the arduino ino file code can not have syntax highlighting. :<
    why ?
    only Ctrl+Shift+B can start the arudino and comiple the code.
    can not use the Ctrl+Shift+T ,and Ctrl+Shift+C (maybe ther soft is used?) , why?

    help me..give me a mail



  • User profile image
    Betteronly

    sorry,i can not use the vscode for arduino.
    i am using the Win10, arduino 1.6.7,and vsCode as 0.10.1.

    i have read and done all the thing of [https://github.com/fabienroyer/VisualStudioCodeArduino],
    but the arduino ino file's code can not have syntax highlighting. :<
    why ?
    only Ctrl+Shift+B can start the arudino and comiple the code. :>>

    can not use the Ctrl+Shift+T ,and Ctrl+Shift+C (maybe ther soft is used?) , why?

    help me..give me a email. thank u.

  • User profile image
    Betteronly

    send me a email please..
    r o l i _ i ce @ 1 6 3. com

  • User profile image
    mp3tobi

    Hey Betteronly,

    I have alreaday opened an issue on fabien's github repo.
    I think it's broken because with the new release of VSCode MS made a few changes of the grunt.js files location.
    But fabien answered me and he maybe will fix this, if he found a workaround.
    Hopefully MS don't change the files for the extensions again.

    VSCode is was a alpha and is beta now. So this could happen with all releases. :)

    Greetings, Tobi

  • User profile image
    Betteronly

    Hi,Tobi
    really,VSCode ver is not the ver of github。
    that is the problem for sure。

    3q very much。

  • User profile image
    rsatchel

    Hi, I'm using VSCode 1.14.0, Arduino 1.8.3 and Fedora 25

    I'm running into troubles in Step 3.  

    In VSCode I navigate to the folder containing my arduino projects (In my case it is ~/Arduino  )

    I bring up the command palette using Ctrl + Shift + P, then type "task" into the command window. I select Configure Task Runner.

    This is where I have problems. It gives me several options to choose from: MSBuild, maven, .NET Core, Others

    However, I have no idea which to choose. 

    Please help!

  • User profile image
    gduncan411

    @rsatchel: I see you've already posted this question on the GitHub repo, hopefully the answer will come there.

    BTW, there's a new VSCode extension from Microsoft available, https://channel9.msdn.com/coding4fun/blog/Visual-Studio-Code-Your-Arduino

Add Your 2 Cents