framework = arduino
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
[env:teensy31]
platform = teensy
board = teensy31
framework = arduino
现在,我们需要创建main.cpp文件,并将其放到新创建项目的src文件夹中。src/main.cpp 的内容:
/**
* Blink
*
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}
最终的项目结构:
project_dir
├── lib
│ └── README
├── platformio.ini
└── src
└── main.cpp
3.2.3 项目处理
PlatformIO Core (CLI) 提供特殊的 pio run 命令来处理项目。如果不带任何参数调用该命令,PlatformIO 编译系统将处理所有项目环境(这些环境是根据上述指定的每个板创建的)。下面是一些有用的命令:
- pio run. 处理(构建)"platformio.ini"(项目配置文件)中指定的所有环境
- pio run --target upload。构建项目并将固件上传到 "platformio.ini"(项目配置文件)中指定的所有设备上
- pio run --target clean. 清理项目(删除编译对象)
- pio run -e uno. 仅处理 uno 环境
- pio run -e uno -t upload。仅为 uno 构建项目并上传固件。
其他目标请参考 pio run --list-targets 文档。
3.2.4 更多参考
3.3 命令简介