How to add Teensy board to VS Code and Arduino plugin?

Viewed 6073

I am currently programming a Teens y2.0 using the Arduino IDE with Teensyduino. It works but Arduino IDE is rubbish, so I would like to use VS Code. However while the Arduino VS code plugin works fine, it doesn't recognise the Teensy as a board, even though Teensyduino installs its libraries etc into the Arduino IDE package.

Does anyone know how to add Teensy support to VS Code or an alternative IDE I can use that will recognise the board?

OSX Sierra / VS Code with vscode-arduino plugin v0.24 / Teensy 2.0

1 Answers

You can use PlatformIO with Visual Studio Code (or with many other major IDEs, or even from the command line). PlatformIO is a build system (sort of like Make, but with a lot more power) for all kinds of embedded platforms.

To get started:

  • Run Visual Studio Code
  • Choose Preferences / Extensions
  • Search for "PlatformIO" and click Install
  • Reload VS Code when prompted
  • In the PIO Home window, click on the BOARDS icon
  • Find your Teensy board. Look in the Platform column and click on Teensy there.
  • This will take you to a screen where you can install the Teensy Platform.

To see it working:

  • Go to the PIO Home (There is a little house icon in the lower left of your VS Code window if you lost it)
  • Click Project Examples
  • Select Teensy > Arduino Blink
  • Find the platformio.ini file it gives you, and delete all the extra sections except for your particular Teensy board
  • In the lower left corner of the VS Code screen, you'll see a checkmark icon which builds and a right arrow icon which installs the HEX file on your Teensy, just like the Arduino editor.

You will still need Teensyduino!

[Hat tip to Mikah Barnett for the answer in the comments]

Related