PlatformIO settings for AVR MCU
Development environment using VS Code and PlatformIO
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
PlatformIO is a plug-in for Visual Studio Code (VSCode). You need to install the following software in advance.
PlatformIO Installation
- Launch VSCode and open the
Extensions
tab. - Enter
PlatformIO IDE
into the search window. - Install the PlatformIO IDE.
Getting Started
Create a new project
- Press the
PlatformIO Home
button to display the PlatformIO home. - Click on
New Project
. - Name your project and select the appropriate board on
Board
. - Open the
main.cpp
in thesrc
folder 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
Build
button to build the project. - Connect Leafony to your PC.
- Press the
Upload
button to write your project to Leafony.
Install the library
- Press the
PlatformIO Home
button to display the PlatformIO home. - Open the
Libraries
tab. - Type
OPT3001
in the search window to search the library for the illuminance sensor OPT3001. ClosedCube OPT3001
をクリック。- Click the
Add to Project
button and add withAdd
. - Open the
PlatformIO.ini
. - Check that
closedcube/ClosedCube OPT3001 @ <version>
is added to thelib_deps
option. - If you paste the code below, you can easily set up the library environment without doing the above.
[env:pro8MHzatmega328]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino
lib_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.0
Writing and Serial Monitor
When you press the Serial Port Monitor
button, the serial monitor is displayed.
Reference
For more information on how to use PlatformIO for VSCode, please refer to the official documentation.
Last modified 01.01.0001