Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 805
AJ. Avatar asked Jul 04 '17 07:07

AJ.


People also ask

Can Teensy run Arduino code?

Most programs written for Arduino work on Teensy. All of the standard Arduino functions (digitalWrite, pinMode, analogRead, etc) all work on Teensy. Teensyduino is also compatible with many Arduino libraries. Teensy is not limited to only serial device type.

How import Arduino library to VS code?

Open VS Code, then open your Arduino library folder by navigating to File > Open Folder.... (or tap CTRL+K then CTRL+O.) Then select the Arduino library folder you'd like to open in the IDE.

What code does Teensy use?

Most projects use Arduino with Teensyduino extensions, or C language to program Teensy. However, a number of other options are available.

How do I use Arduino extension in Visual Studio code?

Installing Arduino ExtensionLaunch VS Code and from the Extensions menu ( Ctrl + Shift + X ) search for “Arduino”. Install the Arduino extension. After installing, reload the IDE. You need to have either Arduino IDE and Arduino CLI already installed in your system in order for the Arduino extension to VS Code to work.


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]

like image 196
Joel Spolsky Avatar answered Oct 07 '22 09:10

Joel Spolsky