Arduino Custom Build Events and Hooks

by Visual Micro 20. March 2017 04:37

Arduino supports many different build events. Visual Micro supports the same events and more. If you can't find an event that meets your needs then please make a request to our forum. Build events are normally placed in the arduino platform.txt system which can be quite convoluted and difficult to test. Licensed users of Visual Micro can opt to use  local project board.txt instead of the usual Arduino locations. The advantage is easier development and testing along with events that are specific to a single project. When making changes to a local board.txt click the "Save" button pior to testing a new build.

The full Arduino build specification is listed here. Visual Micro also provides the following additionl events:-

  • Pre upload event
  • Error during upload event
  • Post upload event (only executes if no error was encountered)

Paste the following into a board.txt to see an attempt to run events. Obviously the example will produce an error because the .bat file will be missing but you will see how it works :)

# before upload event - example

recipe.hooks.deploy.preupload.pattern=cmd.exe /c "c:\hooks_test\test_pre.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

# upload failed event - example

recipe.hooks.deploy.errorupload.pattern=cmd.exe /c "c:\hooks_test\test_error.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

# upload complete event - example

recipe.hooks.deploy.postupload.pattern=cmd.exe /c "c:\hooks_test\test_post.bat" "{build.path}"  "{build.project_name}" "{build.project_path}"

Arduino Shared Cross-Platform Code And Library Development

by Visual Micro 16. January 2017 14:09

news: april 2017 - this functionality is free and in all version from vs2015+

related: shared single code files between projects

Visual Micro makes special use of Visual Studio C++ Shared Projects for both project and library development. C++ shared projects were released in Visual Studio 2015 and are improved in the soon to be released Visual Studio 2017.

Use "File>New>Project>C++>Arduino Library Project" to create a new library project or the "Add Library" menu to create from existing library code. When creating a project from existing library code, the code remains unchanged and compatible with the Arduino IDE. 

There are two types of shared projects that Visual Micro supports. It is important to understand the difference. Shared "library" projects that contain an Arduino format text file in the project root are compiled as Arduino Libraries. Shared "code" projects do not contain a text file. During compilation of shared code projects, the code is merged with the main project code in the temp build folder. In this case the code can be accessed as if it was within the folder structure of the main project.

Multiple main projects can use the same shared project(s). Intellisense in shared projects is powered by the current "Startup Project". A shared project can not be compiled directly, can not be a Startup Project and does not have a fixed platform.

tip: Adding a new library project to an official Arduino library folder will automatically make the library available for use in the Arduino IDE.

Shared projects can be created using the standard Visual Studio new project wizard.

Visual Micro also provides a simple way to create a shared project for an existing Arduino library.

Shared projects that contain an Arduino in the root folder are considered to be Arduino Libraries. If the file does not exist the shared project is considered part of the main project.

The "References" node of a Visual Studio project enables shared projects to be referenced by a master project.

Some of the magic of shared projects is that they do not have a specific architecture. Instead the architecture (intellisense etc) is taken from the "Startup project" of the current Visual Studio solution.

This enables us to develop cross-platform code whilst benefiting from intellisense for a specifc architecture. in fact VS2017RC takes this a step further but that's for another blog.

Using a shared library project is no different to using normal Arduino libraries. In fact they are normal arduino libraries except they also have a .vcxitems file in the library root which simply allows Visual Studio to show the source code during development (in a solution).

Shared library projects must be #included in the code in the same way as a normal Arduino library. The fact that we are using a shared project for development has no bearing on the compilation. The compliation works as normal and compiles the library as it does for all other libraries.

A useful difference between a shared library project and a normal library is that Visual Micro can find the library in any location, not just the published known Arduino library locations. This has many benefits for source control and also versioning.

It is possible to create a shared library project and add it to a solution with a single click.

All users must add a reference to the shared project to the master project(s). Right click the "References" node of a master project in the solution explorer to add the reference to the Shared Project (library). This ensure the intellisense of the shared project will know the correct architecture.

Below are the images of the steps for paid Visual Micro users:-

1) Paid users should switch on "Create a project when adding libraries


2) Add a library to a project in the usual manner.

If the project already uses the library it will not cause an issue. If the lib headers are not required in the .ino file you can remove them.

3) After adding a library, the headers will be inserted into the .ino code as usual. In addition, a new project (with the same name of the library) will be added to the currently open solution (if the library project does not already exists in the solution)

So that intellisense can detect the correct platform, a reference is added to all master projects in the solution that use the library.

Right click the References node of a master project and then click "Add Reference"

4) When the Add Reference window opens, cick the "Shared Projects" tab and put a check mark against the library project(s) you want to use in the current master project.


Three new useful things in Visual Studio

by Visual Micro 6. October 2015 06:09

Visual Studio 2015 comes with many new features and improvements in the IDE, the debugger or language compilers. Obviously, there are more than three things I like in the new IDE, but three things have caught my attention from the very beginning.

The Error Window

One of the things that bothered me the most about the error window was the mixture of errors/warnings/messages from both MSBuild and IntelliSense. But I don’t usually care about the later and their presence in the error window is usually annoying me. This is now fixed and you can select to see messages from Build, IntelliSense or both.
In addition to this you can apply even more filtering:

  • You can select the source of the messages: Entire Solution, Current Project, Open Documents or Current Document.
  • You can search the error list, and the search includes the text in all the output list columns (Code, Description, Project, File or Line).
  • You can individually show or hide Errors, Warnings and Message (but this feature has been available for many years).

The Find in Files Append

In Visual Studio 2015 they have implemented an append feature, were you could append your search results to one of the existing two windows.


As a result the old search results are not discarded, but aggregated in a the form of a tree list in the search results window.


Though this is not what exactly I was expecting it provides the feature I was looking for with probably minimal changes to the Visual Studio IDE.

The Inline Create Definition (for C++)

I’m not sure how this feature is actually called, but what it does is creating a definition for a function in the source file from the declaration in the header and displays it in a boxed document inside the header document. Here is an example:

You declare a function/method in a header file. Visual Studio figures out the definition is missing.
Use the Quick Actions (CTRL + .) to create a definition of the symbol in the source file.
The definition is added to the source file that is opened as a document in a box just below the function declaration.
I find this very useful to get going with a new function. Of course for writing larger functions you’ll probably switch to the actual document tab where the source file is opened.

With these new features only Visual Studio has become much more productive for me. And there are plenty more.

How to create collapsible regions in Arduino code

by Visual Micro 8. April 2015 15:02
#pragma region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor
#pragma region name
#pragma endregion comment



A comment that will display in the code editor.


The name of the region. This name will display in the code editor.


#pragma endregion marks the end of a #pragma region block.

#region block must be terminated with #pragma endregion.


// pragma_directives_region.cpp
#pragma region Region_1
void Test() {}
void Test2() {}
void Test3() {}
#pragma endregion Region_1

int main() {}

Announcing the Wiring Ide for Visual Studio

by Visual Micro 7. March 2015 11:17

The Wiring Ide has been added to the standard list of supported Visual Studio Ide's.

The Wiring Ide gives an interesting alternative to building programs with the Arduino core/backend.

Hardware manufacturers, such as sparkfun electronics, make simple update packs for Wiring that extend the list of available boards that can be developed using the Ide.

Read more

Image of the Wiring Ide hardware being programmed in Microsoft Visual Studio


Exploring Your Arduino Code Using Intellisense

by Visual Micro 12. May 2014 10:53

Exploring Your Code

Both Visual Studio and Atmel Studio have powerful built in tools  that help you when navigating through your code. It is absolutely worth learning to use these functions.

You can...

  • find the places where you declared functions and variables
  • find the places where they were used
  • what functions call other functions
  • and much more

In this aspect, Visual Studio and Atmel Studio differ substantially, because they use different software tools for that purpose.

Atmel Studio

Atmel Studio uses an add-in product, Visual Assist from Whole Tomato Software. This add-is part of the Atmel Studio installation.

Atmel Studio Class Member Dropdown

An automatic class member dropdown in Atmel Studio

You can find Visual Assist's documentation here.

Microsoft Visual Studio

Microsoft Visual Studio has similar functions already built in.

Visual Studio Intellisense Dropdown

An automatic ("Intellisense") class member dropdown in Microsoft Visual Studio

You can find the documentation for Visual Studio here.

Go To Definition

Another useful feature is to right click code and select "GoTo Definition". Doing so will jump directly to the definition of the selected code (where applicable)

Use the tool bar or short cuts to return to the previous code point or use the bookmark system to easily jump between favourite places within your source code


User Guide

Avr Programmers (and others) Usb Driver for Arduino

by Visual Micro 17. January 2014 09:21

This document solves usb driver errors for Arduino programmers. The problem usually happens after installing Atmel Studio. The error will often be:- avrdude: usbdev_open()

Atmel changed the usb driver they install to Jungo which doesn't work with the Arduino Ide and therfore with Visual Micro

This document explains how to switch the driver to one that the Arduino tool chain will work with.

Tested on Xp, Win7 and Win8.1

1) We downloaded the latest release ( of libusb-win32 from but the latest release can be found here

2) Unpack the libusb zip and run the inf-wizard.exe in the bin folder AS ADMINISTRATOR

3) Select the avrisp mkII from the list that appears when you run inf-wizard then click next through the wizard.

4) When prompted select a place on your pc to save the .inf file that the wizard will create. (If you loose the file in the future you can simply repeat the task)

5) When prompted click OK to install the driver.

If required you can run the Atmel Studio 6.1 Jungo driver install again and revert to Atmel Studio drivers with the avrispmkII. 

It is probably also possible to switch back to arduino/avrdude mode by reapplying the .inf created in step 6) via device manager

Sorry about the formatting of the following, it is my fault and caused by conversion from ms word. This update was submiited by Brian M. It explains how to make both the Arduino and Atmel Studio Native commands to work using the same usb driver

Using Atmel's AVRISP mk II Programmer

 with the Visual Micro plug-in for Atmel Studio IDE 

Overview:  When you install the Arduino IDE, a USB driver is installed so that you can use the Atmel AVRISP mk II programmer as an alternative to using the Arduino serial Boot-loader. Also, if you need to actually program an AVR MCU with the bootloader code itself (i.e. if you have a blank Mega328 that has not had the boot-loader firmware pre-installed), you can do so from the Arduino IDE using the Tools/Burn Bootloader function- after having specified the AVRISP mk II as the programmer using Tools/Programmer function.

            When you install Studio 6.1/ 6.2 however, the Atmel installation will install it's own USB driver, which work with the Studio6.x IDE. This is the Jungo driver, and while you have the option of not installing the Jungo driver during the Studio install process, you can't use the Atmel AVRISP mk II nor the Atmel JTAGICE3 without this driver.


The Problem: When you install the Visual Micro plug-in for Studio 6.x, you are most likely to be using the Arduino serial bootloader, since Visual Micro's programming and  debugging capability is based upon the USB-serial link between the PC and the Arduino board. Doing things  this way works fine.

            However, if you decide that you want to use the Atmel AVRISP mk II from within the Visual Micro/Studio 6.x IDE (for downloading your program, or burning the Arduino bootloader), you will find that it doesn't work. You will get an error message to the effect that AVRdude (the programming software used by the Arduino IDE), can't “see” the AVRISP mk II programmer. This happens because Studio6.x uses the Jungo USB driver, and Visual

Micro basically calls the AVRdude programming software (located in the Arduino program folder) just like the Arduino IDE does. AVRdude won't work properly, because its normal USB driver has been replaced by the Jungo driver that Studio6.x has loaded.


The Solution:  What we need is a way to allow the Jungo driver that is associated with the Studio6.x to co-exist with the USB driver that the Arduino IDE uses. That is, we want the Arduino programming routines (i.e. the AVRdude program) to work even with the Atmel Studio6x Jungo driver loaded. This is not too difficult to achieve.

1)   If you want to be certain that Studio6.x has installed the Jungo driver, you can run the Windows Device Manager program, and you will see the following (assuming your AVRISP mk II is plugged in)


2)    The USB driver that the Arduino IDE uses (and therefore Visual Micro) is libusb0.dll. This DLL comes from a larger driver package that installs a basically generic USB driver (which can be used by a variety of Windows applications). This package provides drivers in two formats: stand-alone and filter. The stand-alone format is what the Arduino IDE installs when you run the Arduino setup program. It works fine on its own, but doesn't work with native Atmel Studio6.x tools unless using Visual Micro. If the Atmel Studio usb drivers are installed then we can still program Arduino using Visual Micro but not the Arduino IDE. This can be fustrating if we want all software to work all of the time regardless of Visual Micro. The filter version of the driver works differently. It basically interfaces to your application (Arduino IDE in this case) via the libusb0.dll, but the filter version of the DLL then “massages” the data and forwards it along to the Jungo driver (which is what Studio 6.x uses by default).So, after installing this “filter” version, when you use the “upload using programmer” or “Burn bootloader” functions available in the Tools/Visual Micro toolbar, they will work correctly.

3)   You download the libusb package from the website, by searching for libusb. Pick the libusb-winb32 version. Unzip the downloaded file (libusb-win32-bin- when I did it), navigate to the libusb-win32-bin- folder  and enter  the i86 folder. Plug in your AVRISP mk II now. Then run the install-filter-win program, which will display the following screen:


Press Next, and you should see your Atmel AVRISP mk II in the list:

            Select the AVRISP mk II and hit Install.

            If the AVRISP mk II does NOT appear, it is possible that a libusb driver for it has already been installed (and presumably not the filter version, or you would not be having this problem in the first place).You can go back and select the “remove a device filter” option, and if you see the AVRISP mk II in that list, remove it. Then you should be able to re-try the installation of the filter driver for the AVRIPS mk II. If successful, you should get the following message:

4)   You should now have a libusb0.dll filter driver installed for the AVRISP mk II. You can check for its presence in the Windows/System32 folder under the filename libusb0.dll. You can test the driver using the testlibusb program (in the x86 folder mentioned above):


We're almost done. However, we have to stop the AVRdude program (used by Arduino for programming) from using the libusb0.dll file that it has already installed in its own folder, and use the new (filter version) one that we've just installed. Do do this, we have to “remove” all instances of the libusb0.dll file from within the  c:\program files\arduino folder hierarchy.

The best way to do this is to navigate to the  c:\program files\arduino folder, and do a search for “libusb0.dll. Once you have found them, rename them to libusb0.dll.bak (in case something goes wrong and you need them back again!


            In the case of my XP computer, there were 3 files, and on my 32-bit Win7 computer, there was an additional libusb0-x64.dll file (for 64 bit windows). Once these files are “removed” by renaming them, AVRdude will still look for libusb0.dll, but will only find the filter version in the windows\system32 folder, (where all windows programs look, by default, if they can't find the necessary DLL in their own folder).

            At this point you should be able to open the Studio6.x program and go to the Tools/visual Micro/Programmers tab and select the AVRISP mk II. After you click the “upload  using programmer” tab you should now be able to download programs to your AVR target board using the AVRISP mk II programmer, or use the “burn Bootloader” routine in the Tools/Visual Micro menu bar.

NOTE: to use the Visual Micro USB debugging routines, you will still need to connect your Arduino board to the PC using the standard USB connection cable, as fully described in the Visual Micro documentation.

            This procedure worked for me on both my XP and 32-bit Windows 7 computers, one with Studio6.1 and the other with Studio6.2 and the Visual Micro plug-in.


How to Create Arduino Projects In Visual Studio

by Visual Micro 13. January 2014 11:25

Tips - Opening and creating sketch projects

The easiest way to create a project is to use "File>New>Sketch Project". If you have a solution open already then click "File>Close Solution" before doing so otherwise a 2nd project containing the new Sketch will be added into the current solution. Newer users often find it easier to use one solution per project in the early days of using Visual Studio

To open an existing sketch use "File>Open>Sketch Project". Again close the solution first if open.

Once you become more familiar with Visual Studio you will find there are lots of other ways to open sketches. For example, with the solution closed (an empty Visual Studio Ide) click File>Open>File and navigate to any Arduino sketch then click to open a .pde/.ino. The addin will detect the Arduino sketch and ask you if you want to create a new sketch project. or if a project already exists it will ask you if you want to open it.

Advanced users can simply create a normal empty Visual Studio Win32 C++ project and add a .ino of the same name. Visual Micro will kick in and provide Arduino functionality as normal.

The only rules are the Arduino rule which state that an Arduino sketch must contain a .ino file of the same name as the folder. In Visual Studio the project must also have the same name as the folder and the .ino

So, in summary, the special "Sketch" menu items created by Visual Micro are the best for newer users of Visual Studio. These menu items are also aware of the "SketchBook" folder so position file explorers to where Arduino projects are normally saved.

Serial Ports and Terminal Windows in Visual Studio and Atmel Studio

by Visual Micro 14. September 2013 14:46

The free Visual Micro plugin provides multiple Serial Port Terminals along with "auto-pause for upload" and optional usb "auto detect/re-connect". Serial port "Friendly Names" are optionally provided as part of the Visual Micro + upgrade.

  • Auto-reconnect will detect when the micro-controller has disconnected from the usb. The Ide will automatically reconect when the port becomes available again. This feature can be enabled/disabled in tools options
  • Auto-pause for upload detects when a usb upload to a micro-controller is about to be attempted on a port that is currently open as a terminal window. In this case the terminal will close the port and automatically re-open after the upload completes.
  • Discovery of "friendly" serial port names can be a great help compared to simply seeing COM1 and/or COM2 etc. The friendly name feature is switched on by default and can switched off in the Communications section of Visual Micro "Tools>Options"

An overkill example of many serial terminals and also of many connected devices :)


Switch off Arduino Automatic Prototype Generation

by Visual Micro 5. June 2013 07:59

It is possible to turn off automatic prototype generation in Visual Micro by setting the project property called "Auto Generate Prototypes=False".

The following code will not compile with Arduino or the default Visual Micro, because the function prototype for doLogic() would be automatically inserted before the enum definition.

The only way around this previously was to define your enum in a header which you then included in the main sketch, which is annoying if you want to keep everything all tidy in one file.


typedef enum {RANDOM, IMMEDIATE, SEARCH} StrategyType;

void doLogic(StrategyType s)

void loop()

Extract via capnBry in the forum

How to start the Atmel Studio Arduino simulator

by Visual Micro 5. June 2013 07:44

Visual Micro has a new facility due soon to make this process easier.

In the meantime this document describes how you can run the Atmel Studio simulator with an Arduino project.

NOTE: in 1406+ version of Visual Micro step 1) can be ignored because the compiler copies the output files to the local sketch debug/release folder

1) Switch Tools>Options>Visual Micro>Compiler>Always Show Build Path

2) Build your Arduino project, copy the path that appears in the output window to the windows clipboard (without the file:// prefix)

3) In a new instance of Atmel Studio, click "File>Open Object File For Debugging".

4) When prompted paste the build path and "name of your sketch.elf" into the "Specify Object F To Debug" field (example: c:\user\appdata\vmicro\sketch1\board\sketch1.elf). Give the sim project a name and click OK

4) When Atmel opens the new sim project click "No Tool" on the tool bar and select "Simulator" from the "Debugger/Programmer" drop down list.

5) Start debugging (Debug>Start debugging and break),  the sim will run with your Arduino program

That's it!

nb: Some avr processors are not yet supported by the Atmel Studio Sim

Arduino Code Snippets

by Visual Micro 2. June 2013 18:14

Visual Studio has a powerful snippet and macro system but the VisualAssistX snippet manager in Atmel Studio is just awsome!

Extracted from

Introduction to VA Snippets

VA Snippets are reusable code templates that allow you to quickly insert commonly used code fragments or to surround selected portion of code in the text editor. Used code templates may contain placeholders replaced dynamically, when the snippet is applied, by the meaningful blocks of code. VA Snippets are easy to create, simple to use and allow you to apply extra parameters taken from the context of the surrounding code, from environment variable or simply from your input.

The main advantage of VA Snippets is that they can be modified easily (no XML) to satisfy current needs and used immediately after modifications. Also by modification of specialised VA Snippets you can change behavior of each refactoring and code autocompletion related feature of Visual Assist.

Snippet definition in VA Snippet Editor:
Snippet applied in text editor:


Groups of snippets

VA Snippets can be divided into following groups:
Note: one snippet may appear in multiple groups if it meets the requirements of the each individual group.


  • Snippets using clipboard- Snippets with $clipboard$
    Includes snippets, where $clipboard$ placeholder is used within the body of the snippet definition.
    During applying of these snippets, a text contained in the clipboard is used as a source for the replacement of the$clipboard$ placeholders.
    User can define new such snippets.



  • Snippets for Surround With - Snippets with $selected$
    Includes snippets, where $selected$ placeholder is used within the body of the snippet definition.
    During applying of these snippets, the current selection in the text editor is used as a source for the replacement of the$selected$ placeholders.
    User can define new such snippets.



  • Snippets for Suggestion Lists - Snippets with shortcut
    Includes all snippets with the assigned shortcut.
    Their entries appear in suggestions list when you type their shortcuts in text editor.
    The result is inserted (replaces a written shortcut) after user’s confirmation of the selected snippet entry by pressing Tab orEnter key on keyboard.
    User can define new such snippets.



  • Refactoring snippets
    Specialized snippets used by Visual Assist X for refactoring purposes.
    Code templates contain context and refactoring operation specific placeholders.
    Titles of these snippets always begin with word Refactor.
    User can customize, but cannot create new such snippets.



  • Smart Suggestions
    Highly context-aware code hints suggesting text you're likely to type in the current context.
    With Smart Suggestions, C++ users enjoy C#-like autocompletion for several common scenarios.
    Code of snippets contains lines, where each line of code means one entry in suggestions lists.
    Each of these lines represents individual code template, so you can use expandable placeholders in their definitions.
    User can edit all such snippets, but can create only those for datatypes, so can not create context related.
    Title of these snippets must begin with keyword SuggestionsForType.


Supported placeholders

Placeholders in VA Snippets are keywords to be replaced by meaningful code enclosed by markers. There are two main types of placeholders - those enclosed in dollar '$' signs and Environment Variables enclosed in percent '%' signs.  Remember, that those enclosed in dollar signs are case-sensitive and Environment variables are case-insensiteve, so take care of it during editing or creating snippets.

Supported placeholders are:

  • Reserved Strings
    Predefined placeholders maitained by Visual Assist, their name is enclosed in $ signs.
    User can affect their content only by current IDE settings, project properties, system settings or by positioning caret to specific code context.
    For example, $clipboard$ will always expand to the content of clipboard, $DATE$ will always expand to current system date and so on.
    This group also inlcudes special placeholders usable only within Refactoring snippets.
    Click here to see the complete list of reserved strings with their meaning
  • User Prompts
    User-defined placeholders placed by enclosing meaningful keyword in $ signs.
    To work properly, used keyword must be equal to all its references within snippet definition, and must not be included inReserved strings.  
    During applying process of snippets containing such placeholders, user is prompted for actual values to be used as a result of their expansion.
    The maximum number of user prompts within one snippet is limited to eight.
    Click here for more info about User prompts in VA snippets.
  • Environment Variables 
    In VA Snippets, environment variables are placed as their names enclosed in % signs.
    Unlike other placeholders are case-insensitive, and are expanded before applying of another types of placeholders.
    That enables also a usage of environment variables as a default values in the user defined placeholders.
    Click here for more info about Environment Variables in VA snippets.


First touch - "for" loop

To try how to use VA Snippets to place a “for" loop do following:

  • Ensure that you have opened a C/C++ or a C# project.
  • Place the caret in the text editor to position, where you want to insert a new “for" loop.


  • From IDE’s main menu choose VAssistX -> Insert VA Snippet...


  • In appeared menu choose VA Snippets with shortcuts and then select entry “for loop forward”.

  • Dialog with two input boxes opens:
    The input box labeled “Index” asks for a name of the index variable for the scope, usually programmers use “i”.
    The input box labeled “Length” asks for a number of iterations, so insert for example 100.


  • Click on OK button or press Enter key on keyboard to confirm.
    This is the result:


Now you are ready to insert a “for" loop in simpler way - using shortcut.

  • Move the caret to the position, where you want to insert another “for" loop.
  • In the text editor write “forr” (double “r”) - the shortcut of the predefined For loop snippets.
  • In the suggestion list (which is a Visual Assists’s replacement of intellisense in Visual Studio)
    you should see entries: For loop forwardFor loop reverse and perhaps some other suggestions.
  • Select entry For loop reverse and confirm by pressing Tab or Enter key.


  • Similar dialog as in previous case opens, so insert “i” for index and 100 for length.

  • Click on OK button or press Enter key on keyboard to confirm.
    Follows both results together (current on bottom):


Project Property Window

by Visual Micro 13. April 2013 10:59

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).

Visual Micro currently uses the Arduino project properties tool window to provide additional settings that affect compile and/or debug

note: The property window is a dockable tool window and should not be confused with the Visual Studio "Property Pages" dialog window

How to open the project properties window?

How to manually view the proeperties window for any Visual Studio item. note: Visual Micro only provides properties when a project is selected. note: If a project is not selected the properties window can still be seen but it will contain only a few standard Visual Studio properties so ignore.

Click the project name in the solution explorer then click "View>Project Properties". In some instances of Visual Studio the properties are available on the "View>Other Windows" menu item (see below). Sometime the short cut key is F4 sometimes Ctrl+Enter. 

Arduino -D compiler defines and constants

by Visual Micro 13. April 2013 07:35

Optional defines and constants for the Arduino compiler can be specified using either of two project properties.

Defines - Project

Global defines are included in all compilations


Defines - Configuration


Confirguration specific defines are included in the compilation for a specific configuration such as "Release", "Degug" etc.



During compilation all defines are applied as -D compiler options, so you must ensure they are unique



Alternative Serial Monitors - Arduino Project Settings Remain Unaffected

by Visual Micro 25. October 2012 13:18

The standard "Serial Port" option for Arduino performs two functions. The first to set the upload port of the current project to the selected port, the second is to set the port that the "Serial Monitor" short cut buttons open.

The "Other Serial Ports" menu allows us to open any serial port monitor without changing the current projects upload settings. This is useful if we need to quickly monitor ports other than the port used for uploads without upsetting the current arduino projects' upload settings. 

As with all Visual Micro commands each of the available serial ports will be found in Visual Studio macro list and can be used to assign shortcut keys and quick access menus and buttons. Read more Customizing the Arduino IDE in Visual Studio

Tools>Arduino>Other Serial Ports>Minotor COM[n]

Monitor other serial ports without affecting the arduino upload settings

Other port monitors may still be opened on an Arduino upload port and will be automatically detected, closed and re-opened during upload to an arduino. In this respect they work the same way as the standard serial monitor.

Customize Visual Studio Using Arduino Macros

by Visual Micro 19. October 2012 13:48

The Arduino plugin for Visual Studio automatically creates a Visual Studio macro for every Arduino command. This enables us to add Arduino commands to menus and tool bars. It also allows us to assign shortbut keys to all of the Arduino commands.

Clicking "Customize>Add Command>Addins" on any Visual Studio tool bar or within the menus provides a list of "Visual.Micro" commands as shown below

The following image shows a button that, when clicked, quickly selects a specific Arduino board. In this case a custom board is being selected hence the strange name.

Warning: On rare occassions Visual Studio becomes confused and which causes visual micro menus and tool bar controls to disappear. The documented solution for this problem is to use the visual studio resetaddin command. Running this command will remove any customizations you have made that reference visual.micro macros. I am not currently sure if it is possible to backup your customizations of the visual studio ide. The safest way to work might be to create a visual studio macro that creates the arduino buttons, shortcuts and menus based on visual micro micros. Doing so allows you to re-run your macro and re-create your customizations at any time in the future.

Automate the Arduino IDE for Visual Studio Interface

by Visual Micro 19. September 2012 15:22

We can build our own tool bar layouts or add shortcuts to frequently used Arduino commands to the Visual Studio user interface.

How To

Right click any Visual Studio tool strip and select "Customize" which will on the bottom of the right mouse menu.

When the Customize window opens (see below), click keyboard to assign shortcut keys. Click the  "Commands" tab to add commands to menus and tool bars.

When adding a command or shortcut the Visual Micro commands will be displayed under the "Addins" section 

Below you can see the possibility to add Arduino commands such as board selection to the "File" menu.


Warning: On rare occassions Visual Studio becomes confused and which causes visual micro menus and tool bar controls to disappear. The documented solution for this problem is to use the visual studio resetaddin command. Running this command will remove any customizations you have made that reference visual.micro macros. I am not currently sure if it is possible to backup your customizations of the visual studio ide. The safest way to work might be to create a visual studio macro that creates the arduino buttons, shortcuts and menus based on visual micro micros. Doing so allows you to re-run your macro and re-create your customizations at any time in the future.

Arduino - Memory Usage and Disassembly Reporting

by Visual Micro 24. August 2012 14:29

The August 2012 release of the Arduino plugin for Visual Studio provides useful options to display memory usage and program disassembly reports as part of the Arduino compile process. The disassembly view might not be useful for arduino beginners but the memory usage report might be espcially useful for beginners.

Arduino processors have a relatively small amount of "running" data memory which is often quickly consumed by new users adding their own debug messages to arduino programs. Arduino debug messages are often serial messages such as:- Serial.println("Hello World, I am here at this place in my code!")

Long serial text messages like the one above will quickly fill up the arduino memory which might only be 2048 bytes (characters). Serial messages are just one example of memory consumption. If the Arduino attempts to overflow the available memory it will crash (freeze). A crash is both difficult to debug and also can be quite disasterous so best avoided!

It is true that the arduino has other small memory areas where data could be stored. The other memory areas are for another article and do not remove the need to monitor memory usage.

Arduino Memory Usage Report

The memory uage report is enabled using the visual studio project properties window as shown below. The properties window is displayed by selecting the project node in the viual studio solution explorer and pressing F4 (or "View>Properties Window")

How to enable Arduino memory and disassembly reporting

The arduino memory usage report is automatically displayed after each compile in the "Micro Build" output window shown below. The report shows memory usage after compilation.

NB: The memory usage report does not show the dynamic memory that might be allocated by an arduino program after it has started running on an arduino chip. Dynamic memory can be reported in visual studio using the visual micro debug upgrade or by adding code to your arduino program. See this reference for more info.

Arduino Program Disassembly Report

The disassembly view takes arduino learning to the next level or provides useful information for experienced arduino programers. The disassembly view is automatically displayed in the "Micro Disassembly" output window after each compile (see top picture of how to enable disassembly reports). Below you can see an exampe of the disassembly of the diydrones ArduPilot program


Microsoft Visual Studio Profressional is available for 3 years free (if you are an individual and not a professional web designer or working for a web design company)

The Visual Micro plugin for Visual Studio can be downloaded for free from

Arduino - Learning by Example using Visual Studio and APM

by Visual Micro 24. August 2012 13:02

Selecting an Arduino development tool that provides code assistance is a big help for new arduino users and also to users who are new to a particular arduino program. Features that can be very useful are:- help, examples, code completion, error correction and intellisense.

Help and Examples

Arduino provides a number of examples to help us understand the basics of micro-controller development. Many arduino libraries, created by the community, are also provided with examples.

The "File" menu in the Arduino IDE provides access to all of these examples. In the Arduino IDE we click an example to open it as a new sketch project. In the Arduino IDE, that editing and saving the example will be replaced with modified code. In Visual Studio we get to choose if we would like to create a copy of an example or use the original. We also get a few others options described later on in this page.

Examples are a useful facility and are often overlooked by new users. Examples help us understand the core components of any arduino project. By understanding the core components such as sensors and servos we are able to then create or understand larger Arduino programs.

A good "example" being the ArduPilotMega (APM) drone project. This project has resulted in a few massive but highly crafted arduino programs such as ArduPilot and ArduCopter. The APM hardware involves sensors such as 3 axis:- giro, accelerometer, compass and a gps. The hardware can also drive servos or electronic speed controllers (esc) for rc cars, planes, copters and boards. The heart of the APM circuit board is a standard Arduino micro-processor with some additional sensors ++.

Micro explorer showing apm examples and error correction

At this point I should add that there are other drone projects that use a variety of other arduino based solutions, I am not recomending which is the best I am simply using APM as an example. A reason for using APM as an example is that the project is so incredibly well written, it is an enourmous project that has been re-worked almost to perfection (from an arduino programming point of view!). The code is well formatted, the program is very flexible and can optionally include a large number of different types of sensors (and options). 

A great benfit for new APM users are the examples provided by the community. Every variation of every sensor supported by programs written for APM is available as an example. This makes it possible to write small simple experimental programs or use the examples as they are. These small programs are a great wayt to understand how each sensor, servo, motor, esc, etc. works.

The Visual Studio Arduino plugin provides the micro explorer tool  (shown above) includes these examples but also other reference and tutorials.  The explorer allows arduino examples to be opened, new arduino projects to created from examples and/or to simply open individual example sources for inspection (or copy/paste).

The explorer provides the same refererence examples that are available in the arduino ide with the addition of advanced references for the AVR microcontroller and gcc compiler. The latter being useful for more advanced users. A custom google search facility fixed to, arduino wiki, arduino forum and provides a "www search" without leaving the Visual Studio development tool.

Arduino Code Completion and Intellisense

In the picture below you can see the micro explorer tool providing a drill down into the APM/Arduino example sources. The image also includes source code with an inteltional error to demonstrate Arduino code completion and error correction in Visual Studio.

Pressing the '.' (full stop) automatically displays a list of available members of the object called g in the ArduPilot project. Pressing F12 will goto the definition of an item. SHIFT+F12 will find all references to the currently selected code. All these functions and more are on right click menus and the menus at the top of visual studio.

How to explorer an arduino project using Visual Studio intellisense


For Arduino development, if you do not have a copy of Microsoft Visual Studio then grab a copy of Atmel Studio which is based on Visual Studio 2010 and is free

The Visual Micro plugin for Visual Studio can be downloaded for free from


Arduino avrdude upload error common causes

by Visual Micro 2. June 2012 14:58

Generally there are only a few reasons for avrdude upload errors during arduino serial/bootloader uploads:-

  • The wrong serial port is selected. Answer - Select the correct serial port from the serial ports list
  • The wrong Arduino board is selected. Answer - Select the correct board from the Arduino boards list
  • Tools>Upload using Programmer is incorrectly ticked. Answer - Untick the menu item

Arduino Upload Error Example

Uploading to I/O board using 'COM37'

avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36

Copyright (c) 2000-2005 Brian Dean,

Copyright (c) 2007-2009 Joerg Wunsch

[more detail...]