1. 下载并安装 Arduino IDE:http://www.arduino.cc/en/Main/Software
2. 下载并安装 Eclipse IDE (for C/C++ Developers):http://www.eclipse.org/downloads
3. 安装插件 Arduino eclipse extensions:[Help] => [Eclips Marketplace ...] => Arduino eclipse IDE => [Install]
4. 设置开发环境 Arduino IDE path:
- Windows: [Windows] => [Preferences] => [Arduino] => [Arduino IDE path] => <Arduino IDE 安装路径>
- OS X: [Eclipse] => [Preferences...] => [Arduino] => [Arduino IDE path] => <Arduino IDE 安装路径>
- 在命令行下查看 Arduino IDE 程序包(Arduino.app) 的属性:ls -@l /Applications/Arduino.app
- 如果有额外的属性(例如: com.apple.quarantine)导致设置路径不成功,需要将额外的文件属性去除掉:xattr -d com.apple.quarantine /Applications/Arduino.app
5. 设置编译工具和配置文件的搜索路径:[Windows]/[Eclipse] => [Preferences] => [C/C++] => [Build] => [Build Variables] => [Add ...]
- A.TOOLS.BOSSAC.PATH = ${A.RUNTIME.HARDWARE.PATH}/tools/${A.ARCHITECTURE}
- A.RUNTIME.TOOLS.AVR-GCC.PATH = ${A.RUNTIME.HARDWARE.PATH}/tools/${A.ARCHITECTURE}
6. 创建Arduino项目工程:[File] => [New] => [Project...] => [Arduino] => [New Arduino sketch] => ...
7. 编写测试代码:
// Do not remove the include below
#include "Demo.h"
//The setup function is called once at startup of the sketch
void setup()
{
Serial.begin(115200);
Serial.println("!!! setup done ...");
}
// The loop function is called in an endless loop
void loop()
{
static int counter = 0;
char buffer[64] = { 0 };
snprintf(buffer, sizeof(buffer), "!!! loop %d ...", counter++);
Serial.println(buffer);
delay(1000);
}
8. 编译工程,下载目标文件到开发板 。。。