【问题标题】:Compile and upload to Arduino programmatically以编程方式编译并上传到 Arduino
【发布时间】:2014-07-09 18:32:39
【问题描述】:

我知道使用默认 Arduino IDE 进行基本的 arduino 开发。我正在为我的项目使用 Arduino Pro Mini 5V 板。

我需要能够以编程方式编译程序并将其上传到板上(而不是使用 Arduino IDE 中的按钮)。作为一个实验,我编写了一个基本的“闪烁 LED”示例代码,我希望能够编译然后上传到 Arduino Pro Mini 板 - 全部以编程方式 - 而不是通过默认的 Arduino IDE。

如何通过终端通过 avrdude 编译代码并将其上传到 Arduino Pro Mini,而不是使用原生 Arduino IDE?

/////////////////////////////////////////////////////
// BLINK LED ON ARDUINO PRO MINI (5V)
//
// http://arduino.cc/en/Main/ArduinoBoardProMini
/////////////////////////////////////////////////////

// For blinking an LED in arduino Pro Mini 5V
int blink_led = 13;

// the setup routine runs once when you press reset:
void setup() {          
    // Blink LED is an output pin.
    pinMode(blink_led, OUTPUT);
}

void loop() {
  // BLINK LED
  digitalWrite(blink_led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);               // wait for a second
  digitalWrite(blink_led, LOW);    // turn the LED off by making the voltage LOW
  delay(50);               // wait for a second
}

【问题讨论】:

  • 提示:使用makefile 进行编译(如果不熟悉Makefile 结构,您可以使用现有项目中的makefile 或使用IDE 创建一个新项目。)& 可能还有avrdude 或类似的命令行用于在 arduino 上上传程序的工具。
  • 您发布的代码与您的问题完全无关。

标签: c++ c terminal arduino embedded


【解决方案1】:

你试过Ino吗?这是一个用于构建和上传 Arduino 草图的命令行工具包。他们有一个非常好的Getting Started Guide

【讨论】:

    猜你喜欢
    • 2017-03-22
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    相关资源
    最近更新 更多