环境搭建和例程参考该贴 https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=44761
也按照这个大佬的教程搭建了虚拟机的环境,但是之前没接触过没找到gpio的例程最后没搞下去,不过讲的很好
https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=408&extra=&page=1
1.Arduino
https://blog.csdn.net/ShuaibeiJia/article/details/135315829
参考csdn上的教程安装Arduino
2.软件配置
参考该贴的步骤 [url]https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=44761[/url]
选好对应的板子型号后就可以开始准备点灯了
3.点灯
以下步骤均来自于 https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=44761
仅供大家观看方便
1.本次利用IO2按键进行亮灯控制,第一次长按LED4亮起,三色灯中红,绿,蓝交替,第二次长按LED3亮起,三色灯中红绿蓝各亮二色,组成紫色,青色,黄色交替。第三次长按所有灯熄灭。以上步骤可循环。代码如下:
//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;
}
}
2.烧写固件时点击工具栏上的上传按钮,然后按下Ai-M61-32S-Kit开发板上烧录键(IO2),当下方出现白色字体时说明已编译完成此时按下复位键(EN)并保持1秒后松开,直到出现 橙色字体【All success】 为止再松开IO2。
|