Today I decided to stop using the Arduino IDE because it sucks!
VS Code for Arduino Library Development. If your familiar with VS Code you'll understand that its flexibility means the IDE can be used for just about any programming language out there. This section will help you set up VS Code to develop C, C, or other source files within an Arduino library. Opening an Arduino Library in VS Code. Getting Started with VS Code. Microsoft's Visual Studio (VS) Code IDE is a versatile, free, and open-source code editor. It can be used to develop any application you have in mind - whether the code base is C, C, Python, Javascript, or anything else you find yourself programming in. VS Code is available for all operating systems.
Having worked with Netbeans, MPLAB X and Visual Studio in the past, the Arduino IDE (version 1.8.1) really does not help with development so I am trying the Arduino add-in for Visual Studio Code from Microsoft. The configuring of the environment has proven to be a “not out the box” setup and as such I have documented my steps to get it working (mostly) with Intellisense.
First go to 'Visual Studio Code' Settings and search for the option 'files.associations' If that option is not available in your settings. Please update your Visual. To start debugging in Visual Studio Code I have to generate a Launch.json file. After the file has been auto-generated by Visual Studio Code I've got something like this: 'version': '0.2.0', '.
Contents
Installing the Software Components
You will need two main pieces of software and some add-ons to get started.
First, install the Arduino IDE 1.8.1 or higher but make sure its the Windows installer version, not the app from the Microsoft store as that won’t work. Also, take note of the installation location as you will need that for when configuring the new IDE.
Next, download and instal the Visual Studio Code (VSC) application. During the installation, you will be prompted to choose the languages (extensio0ns) you wish to work with. Select C/C++ and Arduino, as well as any others you are interested in using.
Configuring the Settings
VSC relies on a component of the Arduino IDE to physically upload the code to the board, which is why you needed to note the install location earlier. There are a couple of places this can be added but as several other settings need to be changed, we will do them all in the same file.
From the Explorer window press F1 to bring up the search
Then locate within the settings “Edit in settings.json”.
There may be an easier way of locating this – please comment below if you know of one…
We need to add several items into the JSON file, and I don’t believe the order is important so long as each is separated by a comma and all within the curly braces.
First is the path to the Arduino exe to allow the sketches to be uploaded to the board.
“arduino.path”: “C:Program Files (x86)Arduino”,
Then the list of additional board url’s, which is the same as found in the Arduino IDE File>Preferences> Additional Boards Manager URL’s. For mine, I have Adafruit and ESP8266
“arduino.additionalUrls”: “https://adafruit.github.io/arduino-board-index/package_adafruit_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json“,
And lastly, a modification to make Intellisense work. Without this you will find when you compile a sketch, you will see lots of errors for common commands such as pinMode not being recognised.
“C_Cpp.intelliSenseEngineFallback”: “Disabled”,
“C_Cpp.intelliSenseEngine”: “Tag Parser”
Changes required in settings.json to program the Arduino
To Speed up Compiling
In every new sketch, you are going to need to add this instruction to provide a location to save data about the last compile so as to not need to do a full clean compile every time you change just 1 line.
Adding the compile output path to avoid always doing clean builds
And lastly, select the board type, programmer, serial port from the blue toolbar at the bottom of the window to see the additional parameters in ardunio.json.
Miscellaneous C/C++ Configurations
I am going to say upfront – I have no idea what this section is for other than I needed it for Intellisense. Read about it here if you need more information – https://github.com/microsoft/vscode-arduino/issues/438.
Basically I opened c_cpp_properties.json from, vscode in the tree and replace the existing with the following code.
{
“configurations”: [
{
“name”: “Arduino”,
“includePath”: [
“${workspaceRoot}”
],
“browse”: {
“path”: [
“C:/Program Files (x86)/Arduino/hardware”,
“C:/Program Files (x86)/Arduino/libraries”,
“C:/Users/****/Documents/Arduino/libraries/”,
“C:/Users/****/Documents/Arduino/hardware/”,
“${workspaceRoot}”
],
“limitSymbolsToIncludedHeaders”: true,
“databaseFilename”: “”
},
“intelliSenseMode”: “msvc-x64”
}
],
“version”: 4
}
Final Thoughts
There are still some areas that need tweaking in Visual Studio Code for Arduino for me to be entirely happy with it. One of which is an inconsistent result when trying to upload to the board, which most of the time gives the error “
PlatformIO is a professional collaborative platform for embedded development.
A place where Developers and Teams have true Freedom! No more vendor lock-in!
- Open source, maximum permissive Apache 2.0 license
- Cross-platform IDE and Unified Debugger
- Static Code Analyzer and Remote Unit Testing
- Multi-platform and Multi-architecture Build System
- Firmware File Explorer and Memory Inspection.
Platforms: Atmel AVR, Atmel SAM, Espressif 32, Espressif 8266, Freescale Kinetis, Infineon XMC, Intel ARC32, Intel MCS-51 (8051), Kendryte K210, Lattice iCE40, Maxim 32, Microchip PIC32, Nordic nRF51, Nordic nRF52, NXP LPC, RISC-V, Samsung ARTIK, Silicon Labs EFM32, ST STM32, ST STM8, Teensy, TI MSP430, TI Tiva, WIZNet W7500
Frameworks: Arduino, ARTIK SDK, CMSIS, ESP-IDF, ESP8266 RTOS SDK, Freedom E SDK, Kendryte Standalone SDK, Kendryte FreeRTOS SDK, libOpenCM3, mbed, PULP OS, Pumbaa, Simba, SPL, STM32Cube, Tizen RT, WiringPi, Zephyr RTOS Whatsapp in windows 10.
Features
- Cross-platform code builder without external dependencies to a system software:
- 800+ embedded boards
- 35+ development platforms
- 20+ frameworks
- C/C++ Intelligent Code Completion
- C/C++ Smart Code Linter for rapid professional development
- Library Manager for the thousands of popular libraries
- Multi-projects workflow with multiple panes
- Themes support with dark and light colors
- Serial Port Monitor
- Built-in Terminal with PlatformIO Core tool (
pio
,platformio
)
How it works
!!! PLEASE READ 'QUICK START' AND 'USER GUIDE' BEFORE !!!
Please follow to the official documentation PlatformIO IDE for VSCode.
License
Copyright (C) 2017-present PlatformIO contact@platformio.org
Visual Studio Code Arduino Library Path
The PlatformIO IDE for VSCode is licensed under the permissive Apache 2.0 license,so you can use it in both commercial and personal projects with confidence.
Comments are closed.