eagler8 发表于 2024-1-14 11:12:10

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

本帖最后由 eagler8 于 2024-1-14 11:19 编辑



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







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


#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_32
#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"
#include "myLib/asr_ws2812.h"
#include "asr_math.h"

uint32_t snid;
void hardware_init();

SPITFT spi_tft(128, 160);
WS2812 ASR_WS2812_24(24);
//{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
//{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
//{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
void sys_sleep_hook()
{
digitalWrite(4,1);
digital_write((21),0);

}

void ASR_CODE()
{
//{ID:500,keyword:"命令词",ASR:"绿色灯",ASRTO:"打开绿色灯"}
if(snid == 500){
    digital_write((21),1);
    ASR_WS2812_24.setBrightness(30);
    ASR_WS2812_24.pixel_set_all_color(0,255,0);
    ASR_WS2812_24.pixel_show();
    spi_tft.clear((0xFFFF));
    spi_tft.set_text_color((0x001F),(0xFFFF));
    spi_tft.set_cursor(15,60);
    spi_tft.draw_hanzi_32("绿色灯");
    delay(800);
}
//{ID:501,keyword:"命令词",ASR:"效果不错",ASRTO:"有你的鼓励真好,谢谢啦!"}
if(snid == 501){

}
//{ID:502,keyword:"命令词",ASR:"随机灯",ASRTO:"随机位置三色灯"}
if(snid == 502){
    digital_write((21),1);
    ASR_WS2812_24.setBrightness(30);
    ASR_WS2812_24.pixel_set_color((random(0, 8+1)),255,0,0);
    ASR_WS2812_24.setBrightness(60);
    ASR_WS2812_24.pixel_set_color((random(0, 8+1)),0,0,255);
    ASR_WS2812_24.setBrightness(30);
    ASR_WS2812_24.pixel_set_color((random(0, 8+1)),0,255,0);
    ASR_WS2812_24.pixel_show();
    delay(1000);
    spi_tft.clear((0xF800));
    spi_tft.set_text_color((0xFFFF),(0xF800));
    spi_tft.set_cursor(0,60);
    spi_tft.draw_hanzi_32("随机亮灯");
}
//{ID:503,keyword:"命令词",ASR:"蓝色灯",ASRTO:"打开蓝色灯"}
if(snid == 503){
    digital_write((21),1);
    ASR_WS2812_24.setBrightness(50);
    ASR_WS2812_24.pixel_set_all_color(0,0,255);
    ASR_WS2812_24.pixel_show();
    spi_tft.clear((0xFFFF));
    spi_tft.set_text_color((0x001F),(0xFFFF));
    spi_tft.set_cursor(15,60);
    spi_tft.draw_hanzi_32("蓝色灯");
    delay(800);
}
//{ID:504,keyword:"命令词",ASR:"流光溢彩",ASRTO:"流光溢彩灯"}
if(snid == 504){
    digital_write((21),1);
    ASR_WS2812_24.rainbow(5);
    ASR_WS2812_24.pixel_show();
    spi_tft.clear((0x001F));
    spi_tft.set_text_color((0xFFFF),(0x001F));
    spi_tft.set_cursor(0,60);
    spi_tft.draw_hanzi_32("流光溢彩");
    delay(800);
}
//{ID:505,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
if(snid == 505){
    digitalWrite(4,0);
    digital_write((21),1);
    spi_tft.clear((0x001F));
    spi_tft.set_text_color((0xFFFF),(0x001F));
    delay(800);
    spi_tft.set_cursor(15,40);
    spi_tft.draw_hanzi_24("有什么事");
    delay(800);
    spi_tft.set_cursor(28,80);
    spi_tft.draw_hanzi_24("请吩咐");
}
//{ID:506,keyword:"命令词",ASR:"关闭所有",ASRTO:"关闭所有灯"}
if(snid == 506){
    digital_write((21),1);
    spi_tft.clear((0x001F));
    spi_tft.set_text_color((0xFFFF),(0x001F));
    spi_tft.set_cursor(0,60);
    spi_tft.draw_hanzi_32("关闭所有");
    ASR_WS2812_24.pixel_set_all_color(0,0,0);
    ASR_WS2812_24.pixel_show();
    delay(800);
}
//{ID:507,keyword:"命令词",ASR:"红色灯",ASRTO:"打开红色灯"}
if(snid == 507){
    digital_write((21),1);
    ASR_WS2812_24.setBrightness(30);
    ASR_WS2812_24.pixel_set_all_color(255,0,0);
    ASR_WS2812_24.pixel_show();
    spi_tft.clear((0xFFFF));
    spi_tft.set_text_color((0xF800),(0xFFFF));
    spi_tft.set_cursor(15,60);
    spi_tft.draw_hanzi_32("红色灯");
    delay(800);
}
}

void hardware_init(){
spi_tft.init();
digital_write((21),0);
spi_tft.set_direction(2);
spi_tft.set_text_wrap(true);
spi_tft.set_text_size(32);
spi_tft.set_bg_mode(1);
ASR_WS2812_24.pixel_init(8);
pinMode(4,output);
pinMode(24,output);
digitalWrite(4,1);
vTaskDelete(NULL);
}

void setup()
{
//{speak:娇娇-邻家女声,vol:12,speed:10,platform:haohaodada}
//{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
//{playid:10002,voice:我退下了}
xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
}

训练模型与编译烧录





实验记录视频


【【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机LED灯】 https://www.bilibili.com/video/BV19K411Y7jV/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987

//player.bilibili.com/player.html?bvid=BV19K411Y7jV












页: [1]
查看完整版本: 【花雕动手做】ASRPRO语音识别(36)--流光溢彩和随机WS2812灯