I only recently discovered PlatformIO and I’m so happy about the improved workflow and features compared to the editor of Arduino. No more slow app launch, having auto complete, much better UI and being able to install useful editor extensions is awesome.
I stupidly always thought PlatformIO would be hard to install, configurate and therefor never tried it out. I think it’s mainly the websites fault. But turns out: The opposite is true. It couldn’t be easier to install. Here a small tutorial that hopefully motivates more people to try it out.
Installation
1) Get Visual Code Studio. It’s free and open source.
2) Go to the extension library (the 4th icon on the sidebar), search for PlatformIO and install it. Congrats you have PlatformIO installed.
PlatformIO main page
PlatformIO adds a purple/blue toolbar to the bottom of the window. The home button opens PlatformIO.
The main page allows to browse all your projects, create new ones (even import Arduino ones), browse libraries and find documentation about boards.
Creating a new project
To create a new project simply press on „New project“ on the main page. Select the board you want to use and it automatically creates a project.
Project
The main file is underneath src and is called main.cpp. All other files on the projects sidebar don’t matter to us.
To compile a project click the checkmark and to upload the arrow on the bottom toolbar.
Add libraries to projects
If you want to add additional libraries PlatformIO provides it’s own browser for libraries. Go to PlatformIOs main page via blue home button and click on libraries. It provides all libraries that Arduino also provides in it's editor plus additional.
The overview of each library is much more detailed and better compared to Arduino. You can already take a look inside the files before installing, see changelogs and take a look at examples. To install an extension simply click on „add to project“
Teensy USB type
Open the PlatformIO.ini file from the projects sidebar. And add this entry:
The correct build_flag depends on the usb mode you want. The teensy platform documentation inside the platforms browser lists all.
Yes this step is unfortunately a bit less comfortable compared to Arduino. But at least the the selected usb type gets saved inside the projects.
Where are the code examples for boards and libraries?
Arduino editor provides examples for its boards and installed libraries can also provide examples.
In PlatfromIO examples for platforms/boards can be found by selecting the specific platform inside the platforms browser. Examples for libraries can be found by selecting a specific library in the libraries browser.
I stupidly always thought PlatformIO would be hard to install, configurate and therefor never tried it out. I think it’s mainly the websites fault. But turns out: The opposite is true. It couldn’t be easier to install. Here a small tutorial that hopefully motivates more people to try it out.
Installation
1) Get Visual Code Studio. It’s free and open source.
2) Go to the extension library (the 4th icon on the sidebar), search for PlatformIO and install it. Congrats you have PlatformIO installed.
PlatformIO main page
PlatformIO adds a purple/blue toolbar to the bottom of the window. The home button opens PlatformIO.
The main page allows to browse all your projects, create new ones (even import Arduino ones), browse libraries and find documentation about boards.
Creating a new project
To create a new project simply press on „New project“ on the main page. Select the board you want to use and it automatically creates a project.
Project
The main file is underneath src and is called main.cpp. All other files on the projects sidebar don’t matter to us.
To compile a project click the checkmark and to upload the arrow on the bottom toolbar.
Add libraries to projects
If you want to add additional libraries PlatformIO provides it’s own browser for libraries. Go to PlatformIOs main page via blue home button and click on libraries. It provides all libraries that Arduino also provides in it's editor plus additional.
The overview of each library is much more detailed and better compared to Arduino. You can already take a look inside the files before installing, see changelogs and take a look at examples. To install an extension simply click on „add to project“
Teensy USB type
Open the PlatformIO.ini file from the projects sidebar. And add this entry:
Code:
build_flags = -D USB_MIDI
Yes this step is unfortunately a bit less comfortable compared to Arduino. But at least the the selected usb type gets saved inside the projects.
Where are the code examples for boards and libraries?
Arduino editor provides examples for its boards and installed libraries can also provide examples.
In PlatfromIO examples for platforms/boards can be found by selecting the specific platform inside the platforms browser. Examples for libraries can be found by selecting a specific library in the libraries browser.