PlatformIO

Revision as of 11:05, 28 May 2020 by Qdaniel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Installing PlatformIO

PlatformIO can be either installed as a command line tool or plugin in Visual Studio Code. The latter is preferred for newer users and general use as it includes a code editor (VS Code) and a GUI.

  • First download and install Visual Studio Code
  • Open Visual Studio Code and navigate to Extensions in the sidebar
  • Search for PlatformIO and press install

PIO install.jpg

Getting started

Uploading a Blink demo

  • Press the home button at the bottom of the screen to open the PIO home screen.
  • Select New Project to create a project.
  • Choose a project name and select your board in the drop down menu.

The board used in this demo is an Arduino Nano. The ones available at the CASE lab are of the type Arduino Nano ATmega328 (without new bootloader).

  • Select Framework as Arduino and press finish.

You should now see the project in your workspace. Navigate to project_name/src/ and open main.cpp. This is where your code is written.

  • Copy paste the following code (blink demo) to main.cpp and connect the Arduino to your computer.
#include <Arduino.h>
#define LED 13
// the setup function runs once when you press reset or power the board
void setup() {
 // initialize digital pin LED as an output.
 pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
  • Compile and upload your code by pressing the upload button at the bottom of the screen or with (CTRL + ALT + U).

The inbuilt LED on your arduino should now be blinking if your code was successfully uploaded.

Serial Monitor

Troubleshooting

Upload Port