Description Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. IMPORTANT: This app performs with core functionality on Windows 10 S but some limited plugins do not work. Visual Basic comes as part of Microsoft’s Visual Studio Suite and I initially download and played with Visual Studio Express which in turn lead to Visual Studio Community. Both are free for personal use. Visual Studio Express is a striped down version of the larger packages and has some major limitations.
Arduino IDE is a great tool, but if you need to use Arduino more than just blinking LEDs, you most probably will need a better editor that supports intellisense. Visual Studio Code is an open source editor that's already in the market and already being used for many developers from NodeJS to Python projects. It's not a complete IDE so it's not as heavy as other Microsoft products such as Visual Studio Professional. Vscode is just an editor but with large extensions library; it also provides debugging, syntax highlighting, code refactoring in your projects let it be NodeJs, ReactJS, AngularJS, Python, Lua or whatever...
Using Arduino IDE for small projects just as blinking LED or reading from a sensor then manipulating a switch or a relay is an easy job. But if you need to use multiple sensors and outputting devices such as OLED screens or motors, it means you need to use sophisticated 3rd party libraries. Adafruit or U8GLib is a good example for this. If you want to use your own code rather than copy & pasting other people's code you find on the internet, it's essential that you have intellisense.
Adding this functionality is not very hard. But I had some issues which I figured out how to solve. I hope it helps other people too:
VScode is not a complete IDE, so we still need to have Arduino installed in our system. Then we need to install Arduino extension by Microsoft.
After this setting you will see that .ino file extension is enabled for vscode. Now we need to tell vscode the location of the Arduino so need to make some changes using File -> Preferences -> Settings
'arduino.path': 'C:Program Files (x86)Arduino', 'arduino.additionalUrls': ', 'arduino.logLevel': 'info', 'arduino.enableUSBDetection': true, 'C_Cpp.intelliSenseEngine': 'Tag Parser'
If we included 3rd party libraries, they will be in a different folder than we currently work on. We need to tell vscode where it needs to include those file from. Otherwise we will get below error:
If you hover over the light bulb icon, you will see 'Edit browse.path settings' button.
Clicking it will create a json file called 'c_cpp_properties.json' under .vscode folder of your working directory. In this file you will need to add the path for all the .h files you use.
Now you should see that intellisense working:
After this you can still use Arduino to compile & upload the file to your Arduino, NodeMcu, Wemos, ESP8266 or whatever you're using. But you if you want to use vscode for everything you need to add one more thing. If you look at the bottom right of the editor you will see 2 buttons:
Arduino In Visual Studio
- Select Board Type
- Select Serial Port
If you click them and select your board and ports then you are set to go.
But you won't see compile or upload options in the menu. You will need to click Ctrl + Shift + P
to enable selection menu then click 'Arduino: Upload' option to start compiling and uploading the code to your board.
Take your Arduino Codes to the next level with easy auto completion and documentation in Visual Studio, it's very simple & fast.
- 56,525 views
- 17 comments
- 132 respects
Components and supplies
Apps and online services
|
About this project
Visual Studio + Arduino
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
Visual Micro Requirements
- 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 Studio
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.
Welcome to the world of Visual Studio
Let's start exploring by clicking new Project -> Visual C++
Nothing related to Arduino ? hmm.. Now let's install the Visual Micro plug-in
Installing Visual Micro
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:
- Boards
- Serial Monitor
- COM ports
- Build
- 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
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.
Code Documentation
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.
Arduino IDE Environment Color in Visual Studio
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.
Blinking an LED
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, check out electronic components on utsource.net
Best Regards,
Code
Author
Ahmed Hamdy
- 7 projects
- 107 followers
Published on
February 25, 2016Using Visual Studio For Arduino
Members who respect this project
and 125 others
See similar projectsyou might like