PlatformIO settings for AVR MCU
Introduction
Section titled “Introduction”Instead of the Arduino IDE, you can also use PlatformIO as the Leafony development environment. PlatformIO makes it easy to manage things like library versioning, board configuration, etc., as well as to use. You can take advantage of the powerful plug-ins for Visual Studio Code to make your development more comfortable.
Advance preparation
Section titled “Advance preparation”PlatformIO is a plug-in for Visual Studio Code (VSCode). You need to install the following software in advance.
PlatformIO Installation
Section titled “PlatformIO Installation”- Launch VSCode and open the
Extensionstab. - Enter
PlatformIO IDEinto the search window. - Install the PlatformIO IDE.

Getting Started
Section titled “Getting Started”Create a new project
Section titled “Create a new project”- Press the
PlatformIO Homebutton to display the PlatformIO home. - Click on
New Project. - Name your project and select the appropriate board on
Board. - Open the
main.cppin thesrcfolder and paste the following code.
#include <Arduino.h>
void setup() { // LEDピンを出力ピンに設定 pinMode(LED_BUILTIN, OUTPUT);}
void loop() { digitalWrite(LED_BUILTIN, HIGH); // LEDを点灯 delay(999); // 1秒待つ digitalWrite(LED_BUILTIN, LOW); // LEDを消灯 delay(999); // 1秒待つ}- Press the
Buildbutton to build the project. - Connect Leafony to your PC.
- Press the
Uploadbutton to write your project to Leafony.
Install the library
Section titled “Install the library”- Press the
PlatformIO Homebutton to display the PlatformIO home. - Open the
Librariestab. - Type
OPT3001in the search window to search the library for the illuminance sensor OPT3001. ClosedCube OPT3001をクリック。- Click the
Add to Projectbutton and add withAdd. - Open the
PlatformIO.ini. - Check that
closedcube/ClosedCube OPT3001 @ <version>is added to thelib_depsoption. - If you paste the code below, you can easily set up the library environment without doing the above.
[env:pro8MHzatmega328]platform = atmelavrboard = pro8MHzatmega328framework = arduinolib_deps = closedcube/ClosedCube OPT3001 @ ^1.1.2 adafruit/Adafruit LIS3DH@1.1.2 https://github.com/ameltech/sme-hts221-library.git https://github.com/Leafony/TBGLib tomozh/ST7032@0.0.0-alpha+sha.501bf64fe6 paulstoffregen/MsTimer2@^1.1 adafruit/RTClib@^1.11.2 adafruit/Adafruit Unified Sensor@^1.1.4 adafruit/Adafruit BusIO@^1.5.0Writing and Serial Monitor
Section titled “Writing and Serial Monitor”When you press the Serial Port Monitor button, the serial monitor is displayed.
Reference
Section titled “Reference”For more information on how to use PlatformIO for VSCode, please refer to the official documentation.