Programming

How to Upload Program to Arduino Using PlatformIO IDE for VSCode

When you want to upload a program to Arduino, I think you’ll use Arduino IDE. When I tried to run FreeRTOS on M5Stack, I forgot but Arduino IDE didn’t work as I expected. But, PlatformIO IDE for VSCode worked.
Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success.
PlatformIO: Your Gateway to Embedded Software Development Excellence - PlatformIO
At that time, it’s difficult to find articles how to use PlatformIO IDE for VSCode for me. So, I’ll leave this article as my note. This article explains how to light the LED on Arduino UNO. Please connect Arduino UNO to PC beforehand.

Install PlatformIO IDE for VSCode

Please find “PlatformIO IDE” from VSCode extentions and install.
PlatformIO IDE will be appeared on activity bar after install.

Creating New Project on PlatformIO IDE for VSCode

Please select “Open” under “PIO Home” from “QUICK ACCESS”.
Please click “Create New Project” after selecting “Projects” on PIO Home.
Project Wizard will open, then please input project name / board / framework. After that, please click “Finish” button to create new project.

Upload program to Arduino UNO

Please write code in src/main.cpp.

#include <Arduino.h>

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}

Please push “Build” button after writing a program.
You can see build result in opened terminal after clicking “Build” button.
Please push “Upload” button after completing build.
You can see upload result from opened terminal.

Result

Now you can see lighting LED (near “L”) on Arduino UNO.
zuqqhi2

Share
Published by
zuqqhi2