hack4electronics.com

PlatformIO IDE for VSCode

PlatformIO IDE for VSCode

PlatformIO IDE for VSCode

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.
image copied from : https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start
  • Create a New Project
    • Click on “New Project,” select a board, and create a new PlatformIO Project.
image copied from : https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start
  • Modify the main.cpp File
    • Open the main.cpp file from the src folder and replace its contents with the provided code.
/**
 * 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);
}
image copied from : https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start
  • 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.
image copied from : https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start

Happy coding with PlatformIO!

For more details, refer to the tutorial on the PlatformIO documentation website:

Leave a Reply

Your email address will not be published. Required fields are marked *