感谢安信可社区发放的Ai-M61-32S(第一次写帖子,有误望指出)
看社区很少用离线包搭建arduino环境的(可能没什么挑战),但我看了几篇文章都是用在线直接下载,我用的时候下载很慢而且全部下载失败,我便使用了离线包安装,记录一下。
第一步先安装arduino ide(这就不说了)
下载离线包Release Release V1.0.5-alpha · strongwong/arduino-bl618 (github.com)
(PS:忘了自己哪个名字了,第二个好像是错的)
下载好库之后就会出现所有arduino都会出现一个问题,RGB灯的三个gpio_pin分别是12,14,15但是有两个被定义成立adc的通道,需要我们打开库文件,修改之后将其定义成普通gpio口,用来操作。
打开ide,点灯(代码出处【祖传点灯】安信可Ai-M61-32S+Arduino+点亮RGB灯)
- //const int buttonPin = 2; // 连接按键的引脚
- //int buttonState = 0; // 存储按键状态的变量
- unsigned char count=0;
- void setup() {
- pinMode(12, OUTPUT);
- pinMode(14, OUTPUT);
- pinMode(15, OUTPUT);
- pinMode(27, OUTPUT);
- pinMode(29, OUTPUT);
- pinMode(2,INPUT);
- }
- void loop(){
- //unsigned char buttonState = digitalRead(2);
- if (digitalRead(2) == HIGH) {
- delay(5);
- if (digitalRead(2) == HIGH) {
- while(digitalRead(2) == HIGH);
- count++;
- if(count>=3)count = 0;
- if(count==0){
- digitalWrite(27, LOW);
- digitalWrite(29, LOW);
- }
- else if(count==1){
- digitalWrite(27, HIGH);
- digitalWrite(29, LOW);
- }
- else if(count ==2){
- digitalWrite(27, LOW);
- digitalWrite(29, HIGH);
- }
- }
- }
-
- switch(count){
- //关红,绿,蓝
- case 0:
- digitalWrite(12, LOW);
- digitalWrite(14, LOW);
- digitalWrite(15, LOW);
- break;
- //开红灯,关绿,蓝
- case 1:
- digitalWrite(12, HIGH);
- digitalWrite(14, LOW);
- digitalWrite(15, LOW);
- delay(250);
- //开绿灯,关红,蓝
- digitalWrite(12, LOW);
- digitalWrite(14, HIGH);
- digitalWrite(15, LOW);
- delay(250);
- //开蓝灯,关红,绿
- digitalWrite(12, LOW);
- digitalWrite(14, LOW);
- digitalWrite(15, HIGH);
- delay(250);
- break;
- //开红,蓝灯,关绿
- case 2:
- digitalWrite(12, HIGH);
- digitalWrite(14, LOW);
- digitalWrite(15, HIGH);
- delay(250);
- //开绿,蓝灯,关红
- digitalWrite(12, LOW);
- digitalWrite(14, HIGH);
- digitalWrite(15, HIGH);
- delay(250);
- //开红,绿灯,关蓝
- digitalWrite(12, HIGH);
- digitalWrite(14, HIGH);
- digitalWrite(15, LOW);
- delay(250);
- break;
- default:
- break;
- }
- }
复制代码 功能
|
|