This tutorial needs no prerequisites.
Most of us use Arduino on daily basis. To be honest developing using Arduino IDE is a bit hard as you need to type everything yourself, it gets tedious if you want to keep your code clear and easy to understand
On the other hand, Visual Studio makes the development process so smooth and enjoyable, it helps you with whatever you want. It's also very comfortable for the eye as it has 3 different color schemes.
In this tutorial we'll do the following
- Download and install Visual Studio
- Install Visual Micro
- Upload a sketch to the Arduino using Visual Micro
- Arduino IDE Installed, you can download it here or use this link for windows installer and press " just download " if you don't want to donate
Visual Sutdio is a great tool from Microsoft. It's available in many versions, in this tutorial we'll use the free version ( Visual Studio Community Edition ).
To download Visual Studio, visit this link.
Visual Studio 2015 supports many versions of Windows down to windows 7
Click on Visual Studio 2015, then choose a download version ( ISO /Web Installer)
After you have downloaded the ISO file / Online installer double click on it and launch vs_community.exe (as I'm not connected to the internet the setup will give me a warning because it won't be able to download extra features, but this is pretty fine in our case), then chose the install type custom and a directory of your choice
Next we'll go over to the feature list, make sure you choose C++ ( you don't need windows xp support )
Then hit Next, it takes a while to complete installation
After the setup completes, you can login with your Microsoft account ( @hotmail, ..etc) or you can just Not now, maybe later then choose your favorite color theme
then it'll take a couple of mins to load for the first time.
Let's start exploring by clicking new Project -> Visual C++
Nothing related to Arduino ? hmm.. Now let's install the Visual Micro plug-in
After you've installed Visual Studio with C++, you need to install the FREE plugin which is called Visual Micro, it contains many features such as:
- Serial Monitor
- COM ports
- Build and Upload
- Add library
- Debug code ( not for free )
Click here to download Visual Micro plugin for Visual Studio 2012 to 2015. After downloading you get
then install it
if you have any problems during the installation you can visit the FAQ section here
Now let's run Visual Studio again.
The Visual Micro plugin will ask you about which version of Arduino IDE is installed on your pc and will try to locate it. -make sure the Arduino IDE is installed-
If it doesn't allocate, mostly the Arduino IDE is installed in C:\Program Files (x86)\Arduino
Then choose start trial, you can still use the Visual Micro plugin normally even if the trial ends, it's also free for commercial use! ( I was mistaken when I mentioned before that it wasn't free for commercial use )
and you can also get many extra features if you purchase it
Click Start trial if you'll use it for free
Now, head back to the New Project window, you'll find Arduino Project entry, Choose a name for the solution and click OK.
Now you should notice the following differences
now if I start typing, the suggestion list will popup but it doesn't seem to be very helpful at this moment because it doesn't highlight an entry automatically
IntelliSense is such a great tool in Visual Studio which is one of the biggest reasons why I use Visual Studio to code anything even if it requires a long search for plugins, read more about it and why it can help you learn faster, here
To make IntelliSense auto selects an entry we'll start by opening the Tools menu then select options
Then Text Editor => C/C++ => Advanced
Set the entry of Member List Commit Aggressive to true then click OK, let's try typing again. ( I changed the theme of Visual Studio to Light just for the sake of having clear contrast between the text and background)
Now it highlights the entry normally, you can directly hit the ( . ) -period- and it'll auto complete the typing. then all you need to type is about 2 or 3 letters for each variable instead of the full variable name in Arduino IDE, which makes you easily pickup a slightly long descriptive names for your variables and functions.
It can also give you suggestions by hitting ( CTRL + Space ) then you can browse whatever you can type.
Another great feature of intelliSense is code documentation. Check out the following image.
Can you imagine the power you have now ? just by typing simple comments, they appear as a documentation for functions and variables.
Either you're a code expert or a beginner or anywhere between, this will definitely help you improve your code style and reduces the amount of effort you need to make a good piece of code.
if you really like both the coloring of Arduino and IntelliSense, you can get the best of both worlds by changing the appearance of Visual Studio, in the following image the color is already set to Arduino IDE and it also illustrates how to set it just for the sake of saving space.
Now it's time to give it a try, Connect your Arduino and you'll find it in the port list if all is well.
After you finish typing the code you can either press the green or black play button
After you've finished uploading, open the serial monitor
After you click the Serial Monitor pops up
Congratulations !! :)
Now you can simply and easily make large Arduino projects with Visual Studio and the tools available in it, please respect the project & share the knowledge if you like it.
You can also visit my other tutorials