本例实验使用四路继电器模块
四路继电器模块是一种可以通过单片机或其他数字信号控制的开关模块,它可以实现对高电压或高电流设备的开关控制。
四路继电器模块的电原理如图。
【花雕动手做】实验六十四:激光雕刻的语音控制科普航母模型小智盒子
实验开源代码
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
-
- uint32_t snid;
- void ASR_CODE();
- void hardware_init();
-
- /*描述该功能...
- */
- void ASR_CODE(){
- set_state_enter_wakeup(15000);
- switch (snid) {
- case 0:
- digitalWrite(4,0);
- break;
- case 1:
- digitalWrite(2,0);
- break;
- case 2:
- digitalWrite(2,1);
- break;
- case 3:
- digitalWrite(3,0);
- break;
- case 4:
- digitalWrite(3,1);
- break;
- case 5:
- digitalWrite(5,0);
- break;
- case 6:
- digitalWrite(5,1);
- break;
- case 7:
- digitalWrite(6,0);
- break;
- case 8:
- digitalWrite(6,1);
- break;
- case 9:
- digitalWrite(2,0);
- digitalWrite(3,0);
- digitalWrite(5,0);
- digitalWrite(6,0);
- break;
- case 10:
- digitalWrite(2,1);
- digitalWrite(3,1);
- digitalWrite(5,1);
- digitalWrite(6,1);
- break;
- }
- delay(100);
- //{ID:500,keyword:"唤醒词",ASR:"小智盒子",ASRTO:"金港湾欢迎您的到来!"}
- if(snid == 500){
- digitalWrite(4,0);
- }
- //{ID:501,keyword:"命令词",ASR:"效果不错",ASRTO:"谢谢大家的支持和鼓励!"}
- if(snid == 501){
-
- }
- }
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- void sys_sleep_hook()
- {
- digitalWrite(4,1);
-
- }
-
- void hardware_init(){
- pinMode(4,output);
- digitalWrite(4,1);
- vTaskDelete(NULL);
- }
-
- void setup()
- {
- //{speak:小爱-活泼女声,vol:18,speed:10,platform:haohaodada,version:V3}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用航母管家唤醒我}
- //{playid:10002,voice:我退下了}
- //{ID:0,keyword:"唤醒词",ASR:"航母管家",ASRTO:"欢迎光临金港湾航母基地"}
- //{ID:1,keyword:"命令词",ASR:"一级战备",ASRTO:"已打开警报系统,全舰集合"}
- //{ID:2,keyword:"命令词",ASR:"解除警报",ASRTO:"已经解除,全体休息"}
- //{ID:3,keyword:"命令词",ASR:"战机出库",ASRTO:"打开智能绞盘,飞机升到甲板"}
- //{ID:4,keyword:"命令词",ASR:"战机入库",ASRTO:"打开甲板口,放下飞机回到机库"}
- //{ID:5,keyword:"命令词",ASR:"打开滑行灯",ASRTO:"已经打开三通道舰面跑道滑行灯"}
- //{ID:6,keyword:"命令词",ASR:"关闭滑行灯",ASRTO:"飞行任务结束,已关闭跑道灯"}
- //{ID:7,keyword:"命令词",ASR:"弹射起飞",ASRTO:"打开电磁弹射器,战机弹射起飞"}
- //{ID:8,keyword:"命令词",ASR:"设备收回",ASRTO:"开始快速充电,为下次起飞做准备"}
- //{ID:9,keyword:"命令词",ASR:"全部打开",ASRTO:"测试!测试!打开所有装备"}
- //{ID:10,keyword:"命令词",ASR:"全部关闭",ASRTO:"已关闭所有装备"}
- pinMode(2,output);
- digitalWrite(2,1);
- pinMode(3,output);
- digitalWrite(3,1);
- pinMode(5,output);
- digitalWrite(5,1);
- pinMode(6,output);
- digitalWrite(6,1);
- xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
- }
复制代码
生成模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV1EC411r74W/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
|