本篇讲述在windows Arduino IDE环境下开发BW16-Kit。Arduino开发在国外比较火,像树莓派等都有相关集成与应用。
一.开发环境准备
1.下载官网最新Arduino IDE安装包, 我用的是截至最新版本2.3.1。然后安装。
2.添加开发选项。File->Preferences,在Settings选项卡选择好安装工程路径及URL:https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek_amebad_index.json ,点击"OK"拉取。
3.安装板级包。Tools->Board->Boards mangers...,在搜索框缺省输入real,可看到瑞昱的板级包,如下图,点击安装。
4.选择板级工程。路径如下图,勾选好。
至此,Arduino开发环境初步搭建完成。
二.代码编写、烧录
1.建立工程。File->Examples->01.Basics->Blink
2.修改代码。Blink.ino代码如下
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
printf("Init RGB Pin\r\n");
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_R, HIGH); // turn the LED on (HIGH is the voltage level)
printf("LED_R ON\r\n");
delay(1000); // wait for a second
digitalWrite(LED_R, LOW); // turn the LED off by making the voltage LOW
printf("LED_R OFF\r\n");
delay(1000); // wait for a second
digitalWrite(LED_G, HIGH); // turn the LED on (HIGH is the voltage level)
printf("LED_G ON\r\n");
delay(1000); // wait for a second
digitalWrite(LED_G, LOW); // turn the LED off by making the voltage LOW
printf("LED_G OFF\r\n");
delay(1000);
digitalWrite(LED_B, HIGH); // turn the LED on (HIGH is the voltage level)
printf("LED_B ON\r\n");
delay(1000); // wait for a second
digitalWrite(LED_B, LOW); // turn the LED off by making the voltage LOW
printf("LED_B OFF\r\n");
delay(1000);
}
3.编译。
Sketch->Verify/Compole
4.烧录。
(a)初次在Arduino下烧录先要擦除,Tools->Erase Flash->Enable。
(b)选择好Com口(Tools->Port),关闭IDE外使用的该串口。
(c)依次按下Burn,RST,再松开RST,Burn,板子进入烧录模式。如进不了烧录可参考附录【2】.
(d)Sketch->Upload 下载烧录,烧录成功IDE提示Upload Image done. 信息如下
三.测验
1.在 Arduino IDE 里打开调试串口,步骤如下图,打开时间显示,可以看到运行日志。
2.效果视频如下
RGB_LED_Blink
附录:
【1】AmebaDocs
https://amebaiotdocuments.readthedocs.io/en/latest/ambd_arduino/BW16-TypeC/getting_started/bw16_typec_getting_started.html
【2】关于烧录
https://blog.csdn.net/xh870189248/article/details/121223644