本帖最后由 驴友花雕 于 2024-1-2 19:56 编辑
本例实验采用红外对管
该传感器模块对环境光线适应能力强,其有一对红外线发射与接收管,发射管发射出一定频率的红外线,当检测方向遇到障碍物(反射面)时,红外线反射回来被接收管接收,经过比较器电路处理之后,绿色指示灯会亮起,同时信号输出接口输出数字信号(一个低电平信号),可通过电位器旋钮调节检测距离,有效距离范围 2~30cm,工作电压为 3.3V-5V。该传感器的探测距离可以通过电位器调节、具有干扰小、便于装配、使用方便等特点,可以广泛应用于机器人避障、避障小车、流水线计数及黑白线循迹等众多场合。
红外避障模块电原理图
本例实验采用板载1路继电器:
本例实验采用板载三位独立按键,可以搭配实现各种相关的功能。
本例实验的SPI彩色液晶1.77寸显示屏(ST7735驱动)
TFT177-SPI,型号为SX177QQVGA,像素128X160TFT,驱动芯片为ST7735S,这是一款支持SPI接口的1.77寸TFT彩屏,可以显示文字、图形、图片等内容,提高用户互动体验度。
电原理图
【花雕动手做】实验二十七:双红外对管语音控制TFT彩屏和继电器
实验开源代码
- #define ASC2_12
- #define ST7735_CS_PIN 9
- #define ST7735_CS_GPIO_PIN gpio_pin_1
- #define ST7735_DC_PIN 1
- #define ST7735_DC_GPIO_PIN gpio_pin_1
- #define ST7735_RST_PIN 25
- #define ST7735_RST_GPIO_PIN gpio_pin_1
- #define ST7735_SCK_PIN 3
- #define ST7735_SCK_GPIO_PIN gpio_pin_3
- #define ST7735_MOSI_PIN 2
- #define ST7735_MOSI_GPIO_PIN gpio_pin_2
- #define ASC2_24
- #define ST7735S_RGB_GBR_ORDER 0
-
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
- #include "myLib/asr_st7735.h"
- #include "myLib/asr_event.h"
-
- uint32_t snid;
- void ASR_CODE();
- void hardware_init();
-
- SPITFT spi_tft(128, 160);
- /*描述该功能...
- */
- void ASR_CODE(){
- switch (snid) {
- case 0:
- digitalWrite(21,1);
- spi_tft.clear((0x001F));
- spi_tft.set_text_color((0xFFFF),(0x001F));
- spi_tft.set_cursor(0,60);
- spi_tft.draw_hanzi_32("智能管家");
- break;
- }
- switch (snid) {
- case 3:
- digitalWrite(28,1);
- spi_tft.clear((0xF800));
- spi_tft.set_text_color((0xFFFF),(0xF800));
- spi_tft.set_cursor(0,60);
- spi_tft.draw_hanzi_24("好的马上打开继电器");
- break;
- case 4:
- digitalWrite(28,0);
- spi_tft.clear((0x001F));
- spi_tft.set_text_color((0xFFFF),(0x001F));
- spi_tft.set_cursor(0,60);
- spi_tft.draw_hanzi_24("好的马上关闭继电器");
- break;
- case 5:
- digitalWrite(21,1);
- spi_tft.clear((0xFFFF));
- break;
- case 6:
- digitalWrite(21,0);
- break;
- }
- //{ID:500,keyword:"命令词",ASR:"效果还行",ASRTO:"有你的鼓励挺好,谢谢"}
- if(snid == 500){
- digitalWrite(21,1);
- spi_tft.clear((0xFFFF));
- spi_tft.set_text_color((0xF800),(0xFFFF));
- spi_tft.set_cursor(30,60);
- spi_tft.draw_hanzi_32("谢谢");
- }
- }
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- void hardware_init(){
- spi_tft.init();
- spi_tft.set_direction(2);
- spi_tft.set_text_wrap(true);
- spi_tft.set_text_size(24);
- spi_tft.set_bg_mode(1);
- pinMode(4,input);
- setPinFun(4,FIRST_FUNCTION);
- pinMode(18,input);
- dpmu_set_adio_reuse(PC2,DIGITAL_MODE);
- dpmu_set_io_pull(pinToFun[18],DPMU_IO_PULL_UP);
- setPinFun(18,SECOND_FUNCTION);
- pinMode(19,input);
- dpmu_set_adio_reuse(PC3,DIGITAL_MODE);
- dpmu_set_io_pull(pinToFun[19],DPMU_IO_PULL_UP);
- setPinFun(19,SECOND_FUNCTION);
- while (1) {
- if(!(digitalRead(4))){
- digitalWrite(28,0);
- digitalWrite(21,0);
- delay(200);
- enter_wakeup(2000);
- delay(200);
- //{ID:501,keyword:"命令词",ASR:"耍接官",ASRTO:"关闭所有"}
- play_audio(501);
- delay(1000);
- }
- if(!(digitalRead(19))){
- digitalWrite(28,1);
- delay(200);
- enter_wakeup(2000);
- delay(200);
- //{ID:502,keyword:"命令词",ASR:"接耍官",ASRTO:"打开继电器"}
- play_audio(502);
- }
- if(!(digitalRead(18))){
- digitalWrite(21,1);
- delay(200);
- enter_wakeup(2000);
- delay(200);
- //{ID:503,keyword:"命令词",ASR:"官耍接",ASRTO:"打开彩屏背光"}
- play_audio(503);
- spi_tft.clear((0xFFFF));
- delay(1000);
- }
- delay(100);
- }
- vTaskDelete(NULL);
- }
-
- void setup()
- {
- digitalWrite(21,0);
- //{speak:小伦-日常,vol:18,speed:10,platform:haohaodada,version:V3}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
- //{playid:10002,voice:我退下了}
- //{ID:0,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
- //{ID:3,keyword:"命令词",ASR:"打开继电器",ASRTO:"好的,马上打开继电器"}
- //{ID:4,keyword:"命令词",ASR:"关闭继电器",ASRTO:"好的,马上关闭继电器"}
- //{ID:5,keyword:"命令词",ASR:"打开背光",ASRTO:"好的马上执行"}
- //{ID:6,keyword:"命令词",ASR:"关闭背光",ASRTO:"好的马上执行"}
- pinMode(28,output);
- setPinFun(28,FIRST_FUNCTION);
- pinMode(21,output);
- setPinFun(21,SECOND_FUNCTION);
- xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
- }
复制代码
训练模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV12K411472a/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
|