设为首页 加入收藏

TOP

物联网开发平台PlatformIO手册(上)(四)
2023-09-09 10:25:35 】 浏览:119
Tags:平台 PlatformIO 手册
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 命令简介

首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇电机控制和Linux驱动开发哪个方向.. 下一篇物联网开发平台PlatformIO手册(中..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目