③语音识别控制灯的图形化编程代码和Python编程
- MindPlus
- mpython
*/
#include
#include
// 函数声明
void onButtonAPressed();
void obloqMqttEventT1(String& message);
// 静态常量
const String topics[5] = {“T_GCbjdGg”,“OklCbjdGg”,””,””,””};
const MsgHandleCb msgHandles[5] = {NULL,obloqMqttEventT1,NULL,NULL,NULL};
// 创建对象
DFRobot_Iot myIot;
// 主程序开始
void setup() {
mPython.begin();
myIot.setMqttCallback(msgHandles);
buttonA.setPressedCallback(onButtonAPressed);
myIot.wifiConnect(“xiaoxian”, “123456”);
display.setCursorLine(1);
display.printLine(“正在连接 络”);
while (!myIot.wifiStatus()) {yield();}
display.setCursorLine(2);
display.printLine(“连接 络成功”);
display.fillScreen(0);
delay(2000);
myIot.init(“iot.dfrobot.com.cn”,“q0uh-COMR”,””,“qAX2-jOGRz”,topics,1883);
myIot.connect();
while (!myIot.connected()) {yield();}
display.setCursorLine(1);
display.printLine(“mqtt连接成功”);
delay(3000);
display.fillInLine(1, 0);
}
void loop() {
}
// 事件回调函数
void onButtonAPressed() {
while (!(!buttonA.isPressed())) {yield();}
myIot.publish(topic_0, “吴春贤”);
display.fillScreen(0);
display.setCursorLine(1);
display.printLine(“发送消息成功”);
delay(3000);
display.fillInLine(1, 0);
}
void obloqMqttEventT1(String& message) {
display.setCursorLine(1);
display.printLine(“您有新的消息!”);
rgb.write(-1, 0x0000FF);
display.setCursorLine(2);
display.printLine(message);
delay(3000);
rgb.write(-1, 0x000000);
display.fillScreen(0);
}
三、总结
本次实战案例主要介绍了四种,关于软件平台还有很多,就不一一介绍了,对图形化感兴趣的朋友们,可以多去查找资料,如果有什么问题需要请教,可以给我留言,感谢大家!写得不是很好,请大家海涵!
文章知识点与官方知识档案匹配,可进一步学习相关知识Python入门技能树首页概览211022 人正在系统学习中
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!