Visual Studio Code (VSCode) is a lightweight yet powerful source code editor available for Windows, macOS, and Linux. It comes with built-in support for JavaScript, TypeScript, and Node.js, and has a rich ecosystem of extensions for other languages (such as C++, C#, Python, PHP, Go) and runtimes (such as .NET and Unity).
This tutorial introduces you to the basics of the PlatformIO IDE workflow and guides you through the creation of a simple “Blink” example. By the end, you will have a general understanding of how to work with projects in the IDE.
Setting Up the Project
- Open PlatformIO Home
- Click on the “PlatformIO Home” button on the bottom PlatformIO Toolbar.
- Create a New Project
- Click on “New Project,” select a board, and create a new PlatformIO Project.
- Modify the main.cpp File
- Open the
main.cpp
file from thesrc
folder and replace its contents with the provided code.
- Open the
/**
* Blink
*
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 13
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}
- Build Your Project
- Use the
Ctrl+Alt+B
hotkey to build your project (see all key bindings in the “User Guide” section below) or click the “Build” button on the PlatformIO Toolbar.
- Use the
Happy coding with PlatformIO!
For more details, refer to the tutorial on the PlatformIO documentation website: