Teensy for Microsoft Visual Studio and Atmel Studio

News: May 17th 2015 - Teensy for Arduino 1.6.2+ is now supported and recommended. Visual Micro provides teensy options via menus so please remove any defines from your 1.0.x projects such as F_CPU when switching to 1.6.x.

Build programs and uploading to Teensy boards is much simpler in Visual Micro versions 1505.17+ using the "Board Options" menus. The compiler changes that automatically occurr as a result of the various menu choices are also automatically fed into the Visual Studio intellisense system providing dynamic assisance in the code editor.

If options are not selected then the first in each list will automatically be applied. Options can be changed at any time which will cause a full re-compile the next time the project is built. Intellisense will automatically change to reflect the selection.

There are two user interface compents to choose between depending on your prefered way of working:-

1. The "Tools>Visual Micro>Board Options" menu will automatically display the published options for each type of Teensy board


2. The board options tool bar will appear automatically for new Visual Micro users. Existing users need to click "tools>visual micro>reset user interface" before the bar will appear.

As with all tool bars, this bar can be hidden or removed if required (right click>customise) it will not re-appear until you unhide it or use the reset command described above.


Please note that the default Visual Micro debugger transport is serial usb. With teensy the usb can be disabled entirely in this case the debugger will not work unless you switch to using alternative port or pins (see user guide)

Obsolete instructions for Arduino 1.0 version of TeensyDuino follow ....

New users please note: You must have opened and used the teensy IDE to upload at least one sketch prior to using the information on this page. This is so that you understand what is involved in programming Teensy the normal way. + You to open or created a sketch project using Visual Micro (see the Documentation) before the information on this page can be used.

There are two steps required to configure a Visual Studio or Atmel Studio project for a Teensy board:-
Step 1) Select the teensy board using the tool bar (or tools menu) command

Step 2) To compile for a Teensy board we need to set three Teensy options which reflect the additional Tools menu options in the Teensyduino IDE (such as cpu speed, keyboard language).
  •          Click the project in the solution explorer
  •          Click the menu View > Other Windows > Properties Window
  •          Edit Micro General > Defines Project as follows:-

Teensy 3.x running at 96mhz, Mode supporting USB Serial and acting as a Keyboard with language US English


Teensy 2.0 running at 16mhz, Mode supporting USB Serial and acting as a Keyboard with language US English

Teensy define hints (keyboard/joy, serial, serial + keyboard/joy:-

In versions of Visual Micro since Sept 2013 clicking the yellow question mark ? icon on the toolbar, when a sketch is open, will select the project and display the project properties (tool window). You can read more about the project property window here

Understanding Additional Teensy Configuration Options

To gain Teensy functionality install the Teensyduino IDE from pjrc.com (which is really just an updated Arduino Ide) and then in the Visual Micro "Ide Locations" window select the Teensy 1.0 app name, then set the location to the Arduino IDE folder. That's it, just click OK and all the boards should appear on the Visual Micro tool bar.

The standard Teensy defines mentioned above can be found in the boards.txt file which can be found under the [Arduino IDE folder]/Hardware/Teensy/. See the tags "build.definen" and "build.f_cpu"

** NOTE **
If you change the defines then click "Build>Clean Solution" to force a complete re-compile the next time the project is built.

If you change the defines often then there are two project properties in the "Micro Optimization" category called "Project Defines Affect Core" and "Project Defines Affect Libraries". Setting these to true would automatically perform a build clean prior to compile if the project defines have changed.

If you do not do this then your Teensy could become confused about usb/keyboard emulation or run at the wrong speed.


Serial and Teensy?

With Teensy we can configure how the usb port will perform. For example; as serial, joystick, keyboard, midi etc. To do this we set a few compiler defines as described below. One point to note is that by default Teensy does not enable the Serial object so we can not use Serial.println() in code and the Visual Micro debugger will not work (in its default state).

Teensy has another serial port called Serial1. You can connect the serial1 pins>usb and use it for your own serial communications or as an alternative debugger port.

For the debugger please see "Debugging using Different ports and pins" in the documentation section (RemotePort can be equal to Serial1 or you can use SoftwareSerial). Alternatively, switch off debug (change the configuration from debug to Release) and do not sue Serial print in your own code.