Use PlatformIO to program Onboard Arduino GPIO on LattePanda

userHead Youyou 2024-06-26 11:49:46 148 Views0 Replies

Overview

PlatformIO is a cross-platform, cross-architecture, multiple framework, professional tool for embedded systems engineers and for software developers. While the Arduino IDE is sufficient for simple projects and beginners, PlatformIO offers a more robust, feature-rich environment suited for professional development and more complex projects. It provides advanced features like intelligent code completion and efficient code navigation.

 

PlatformIO is a plugin that relies on editors like Visual Studio Code (VSCode). It can be installed in VSCode and integrated into other development environments such as CLion.

 

This tutorial will use VSCode and PlatformIO as examples to demonstrate step-by-step how to program the onboard Arduino Leonardo GPIO on a LattePanda.

 

Requirement

Hardware

any LattePanda board (except LattePanda Mu)

Software

Visual Studio Code(VSCode)

 

Step

1. Download Visual Studio Code and proceed with the installation process.

 

2. Open the application, locate and click on the 'Extensions' button. Search for 'platformio' in the search bar, and then select the 'Install' button of the PlatformIO IDE option.

 

3. Installation time ranges from 3 to 10 minutes, depending on the network condition. Once the installation is complete, you will be prompted to restart VSCode.

 

4. After installing, click the 'PlatformIO' button to open the PlatformIO welcome page. Click 'Open' -> 'New Project'.

 

Fill in the relevant information in the pop-up dialog box, select Arduino Leonardo as the Board, as shown in the following image, then click Finish. When using this framework for the first time, it will automatically download the necessary toolchain, so please be patient.

 

5. After the toolchain installation is complete, a full project will be automatically created as shown in the figure below.

Modify the main.cpp file in the src directory of the project to the following code.

 

#include <Arduino.h>
void setup() 
{
 pinMode(13,OUTPUT);
}
void loop() 
{
 digitalWrite(13,HIGH);
 delay(500);
 digitalWrite(13,LOW);
 delay(500);
}

 

6. Select the COM port corresponding to the Arduino Leonardo, then click the upload button. You will see the LED on pin 13 start blinking.

 

 

More Reference

Arduino PlatformIO latest documentation

 

Other program methods for Arduino GPIO

C++ with Arduino IDE

Python with pyFirmata

Python with Pinpong