929浏览
查看: 929|回复: 0

[项目] 【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯

[复制链接]
本帖最后由 驴友花雕 于 2024-1-14 11:18 编辑

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图1

本例实验采用直条八位WS2812B灯模块
主要特点:
1、5050高亮LED,内置控制芯片,仅需1个IO口即可控制多个LED模块
2、芯片内置整形电路,信号畸变不会累计,稳定显示
3、三基色256级亮度调剂,16万色真彩显示效果,扫描频率不低于400Hz/S
4、串行级联接口,能通过一根信号线完成数据的接收与解码
5、刷新速率30帧/秒时,低速连级模式连级数不小于512点
6、数据收发速度最高可达800Kbps
7、高亮LED,光色亮度一致性高
8、两端有连级接口,可以直接插接


【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图2
【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图3


【花雕动手做】实验四十一:随机位置三色直条8位流光溢彩WS2812B灯
实验开源代码


  1. #define ASC2_12
  2. #define ST7735_CS_PIN 9
  3. #define ST7735_CS_GPIO_PIN gpio_pin_1
  4. #define ST7735_DC_PIN 1
  5. #define ST7735_DC_GPIO_PIN gpio_pin_1
  6. #define ST7735_RST_PIN 25
  7. #define ST7735_RST_GPIO_PIN gpio_pin_1
  8. #define ST7735_SCK_PIN 3
  9. #define ST7735_SCK_GPIO_PIN gpio_pin_3
  10. #define ST7735_MOSI_PIN 2
  11. #define ST7735_MOSI_GPIO_PIN gpio_pin_2
  12. #define ASC2_32
  13. #define ST7735S_RGB_GBR_ORDER   0
  14. #include "asr.h"
  15. extern "C"{ void * __dso_handle = 0 ;}
  16. #include "setup.h"
  17. #include "myLib/asr_st7735.h"
  18. #include "myLib/asr_event.h"
  19. #include "myLib/asr_ws2812.h"
  20. #include "asr_math.h"
  21. uint32_t snid;
  22. void hardware_init();
  23. SPITFT spi_tft(128, 160);
  24. WS2812 ASR_WS2812_24(24);
  25. //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
  26. //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
  27. //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
  28. void sys_sleep_hook()
  29. {
  30.   digitalWrite(4,1);
  31.   digital_write((21),0);
  32. }
  33. void ASR_CODE()
  34. {
  35.   //{ID:500,keyword:"命令词",ASR:"绿色灯",ASRTO:"打开绿色灯"}
  36.   if(snid == 500){
  37.     digital_write((21),1);
  38.     ASR_WS2812_24.setBrightness(30);
  39.     ASR_WS2812_24.pixel_set_all_color(0,255,0);
  40.     ASR_WS2812_24.pixel_show();
  41.     spi_tft.clear((0xFFFF));
  42.     spi_tft.set_text_color((0x001F),(0xFFFF));
  43.     spi_tft.set_cursor(15,60);
  44.     spi_tft.draw_hanzi_32("绿色灯");
  45.     delay(800);
  46.   }
  47.   //{ID:501,keyword:"命令词",ASR:"效果不错",ASRTO:"有你的鼓励真好,谢谢啦!"}
  48.   if(snid == 501){
  49.   }
  50.   //{ID:502,keyword:"命令词",ASR:"随机灯",ASRTO:"随机位置三色灯"}
  51.   if(snid == 502){
  52.     digital_write((21),1);
  53.     ASR_WS2812_24.setBrightness(30);
  54.     ASR_WS2812_24.pixel_set_color((random(0, 8+1)),255,0,0);
  55.     ASR_WS2812_24.setBrightness(60);
  56.     ASR_WS2812_24.pixel_set_color((random(0, 8+1)),0,0,255);
  57.     ASR_WS2812_24.setBrightness(30);
  58.     ASR_WS2812_24.pixel_set_color((random(0, 8+1)),0,255,0);
  59.     ASR_WS2812_24.pixel_show();
  60.     delay(1000);
  61.     spi_tft.clear((0xF800));
  62.     spi_tft.set_text_color((0xFFFF),(0xF800));
  63.     spi_tft.set_cursor(0,60);
  64.     spi_tft.draw_hanzi_32("随机亮灯");
  65.   }
  66.   //{ID:503,keyword:"命令词",ASR:"蓝色灯",ASRTO:"打开蓝色灯"}
  67.   if(snid == 503){
  68.     digital_write((21),1);
  69.     ASR_WS2812_24.setBrightness(50);
  70.     ASR_WS2812_24.pixel_set_all_color(0,0,255);
  71.     ASR_WS2812_24.pixel_show();
  72.     spi_tft.clear((0xFFFF));
  73.     spi_tft.set_text_color((0x001F),(0xFFFF));
  74.     spi_tft.set_cursor(15,60);
  75.     spi_tft.draw_hanzi_32("蓝色灯");
  76.     delay(800);
  77.   }
  78.   //{ID:504,keyword:"命令词",ASR:"流光溢彩",ASRTO:"流光溢彩灯"}
  79.   if(snid == 504){
  80.     digital_write((21),1);
  81.     ASR_WS2812_24.rainbow(5);
  82.     ASR_WS2812_24.pixel_show();
  83.     spi_tft.clear((0x001F));
  84.     spi_tft.set_text_color((0xFFFF),(0x001F));
  85.     spi_tft.set_cursor(0,60);
  86.     spi_tft.draw_hanzi_32("流光溢彩");
  87.     delay(800);
  88.   }
  89.   //{ID:505,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
  90.   if(snid == 505){
  91.     digitalWrite(4,0);
  92.     digital_write((21),1);
  93.     spi_tft.clear((0x001F));
  94.     spi_tft.set_text_color((0xFFFF),(0x001F));
  95.     delay(800);
  96.     spi_tft.set_cursor(15,40);
  97.     spi_tft.draw_hanzi_24("有什么事");
  98.     delay(800);
  99.     spi_tft.set_cursor(28,80);
  100.     spi_tft.draw_hanzi_24("请吩咐");
  101.   }
  102.   //{ID:506,keyword:"命令词",ASR:"关闭所有",ASRTO:"关闭所有灯"}
  103.   if(snid == 506){
  104.     digital_write((21),1);
  105.     spi_tft.clear((0x001F));
  106.     spi_tft.set_text_color((0xFFFF),(0x001F));
  107.     spi_tft.set_cursor(0,60);
  108.     spi_tft.draw_hanzi_32("关闭所有");
  109.     ASR_WS2812_24.pixel_set_all_color(0,0,0);
  110.     ASR_WS2812_24.pixel_show();
  111.     delay(800);
  112.   }
  113.   //{ID:507,keyword:"命令词",ASR:"红色灯",ASRTO:"打开红色灯"}
  114.   if(snid == 507){
  115.     digital_write((21),1);
  116.     ASR_WS2812_24.setBrightness(30);
  117.     ASR_WS2812_24.pixel_set_all_color(255,0,0);
  118.     ASR_WS2812_24.pixel_show();
  119.     spi_tft.clear((0xFFFF));
  120.     spi_tft.set_text_color((0xF800),(0xFFFF));
  121.     spi_tft.set_cursor(15,60);
  122.     spi_tft.draw_hanzi_32("红色灯");
  123.     delay(800);
  124.   }
  125. }
  126. void hardware_init(){
  127.   spi_tft.init();
  128.   digital_write((21),0);
  129.   spi_tft.set_direction(2);
  130.   spi_tft.set_text_wrap(true);
  131.   spi_tft.set_text_size(32);
  132.   spi_tft.set_bg_mode(1);
  133.   ASR_WS2812_24.pixel_init(8);
  134.   pinMode(4,output);
  135.   pinMode(24,output);
  136.   digitalWrite(4,1);
  137.   vTaskDelete(NULL);
  138. }
  139. void setup()
  140. {
  141.   //{speak:娇娇-邻家女声,vol:12,speed:10,platform:haohaodada}
  142.   //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
  143.   //{playid:10002,voice:我退下了}
  144.   xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
  145. }
复制代码


训练模型与编译烧录

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图4

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图5

实验记录视频


https://www.bilibili.com/video/BV19K411Y7jV/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987



【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图7

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图6

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图8

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图9

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图10

【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯图11
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail