I prefer to use the Visual Studio 2008 environment to write and test code for the Arduino. The following steps outline what is necessary to accomplish this.
Note that this requires two files to be added that are stub’s for the normal Arduino functions. The stubs provided here use defines for the Arduino Mega and create a simple console application that will map console input/output to the Arduino serial input/output.
For those of you who have more time at hand, it would be nice to write a windows stub which will also allow to see / control the I/O pins.
If you need support for other boards you need to edit the VSPDE.h file.
Also the VSPDE.cpp file does not implement all the Arduino functions, so if you need more, please feel free to update the code.
Main objective for me was to be able to edit and compile, and in a limited way run and debug code using Visual Studio. This will do just that (and nothing more)!
Step 1: Ensure .pde files are seen as C++ files
Open regedit and under \HKEY_CLASSES_ROOT create a new key called “.pde” and change the default value to “cppfile”.
Step 2: Configure Visual Studio
- Under tools \ options \ Projects and Solutions\VC++ Project settings add ‘*.pde’ to ‘C/C++ File Extensions’ and ‘.pde’ to the ‘Extensions to Include’
- Under tools\options\Text Editor\File Extension add PDE and map it to the C++ editor
- Close Visual Studio to effect the changes
Step 3: Create a Visual Studio project
- Start by creating a new (empty) sketch using the Arduino editor
- Next create a Visual C++ ‘Empty Project’ for the sketch in the same folder
- In the solution, right click and select Add, Existing item to add the .PDE file(s)
- Select the .PDE files, right click and in the file properties set the file type to ‘C/C++ Code’
- Add the VSPDE.h and VSPDE.cpp files
- Add an #include statement for the VSPDE.h file in the .pde files.
- You can now edit, compile and run the program as a console application (without I/O support!)
Step 4: Configure Arduino
Under File\Preferences set the ‘Use external editor’ checkmark.
Now you can use Visual studio to edit and when done just Alt-Tab to the Arduino application and press the upload button to compile the latest code and upload it to the board. The Arduino program will automatically monitor for file changes so you do not need to refresh anything!
- Swift – Simple full screen loader - 11 August 2022
- macOS – Disable microphone while typing - 11 April 2022
- iOS – Secure app sensitive information - 25 March 2022