【花雕动手做】ASRPRO语音识别(41)---64位WS2812B点阵屏模块
本帖最后由 驴友花雕 于 2024-1-17 15:30 编辑本例实验使用64位WS2812点阵屏模块
知识点:WS2812B芯片
是一个集控制电路与发光电路于一体的智能外控LED光源。其外型与一个5050LED灯珠相同,每个元件即为一个像素点。像素点内部包含了智能数字接口数据锁存信号整形放大驱动电路,还包含有高精度的内部振荡器和12V高压可编程定电流控制部分,有效保证了像素点光的颜色高度一致。
数据协议采用单线归零码的通讯方式,像素点在上电复位以后,DIN端接受从控制器传输过来的数据,首先送过来的24bit数据被第一个像素点提取后,送到像素点内部的数据锁存器,剩余的数据经过内部整形处理电路整形放大后通过DO端口开始转发输出给下一个级联的像素点,每经过一个像素点的传输,信号减少24bit。像素点采用自动整形转发技术,使得该像素点的级联个数不受信号传送的限制,仅仅受限信号传输速度要求。
LED具有低电压驱动,环保节能,亮度高,散射角度大,一致性好,超低功率,超长寿命等优点。将控制电路集成于LED上面,电路变得更加简单,体积小,安装更加简便。
WS2812B主要特点
1、智能反接保护,电源反接不会损坏IC。
2、IC控制电路与LED点光源公用一个电源。
3、控制电路与RGB芯片集成在一个5050封装的元器件中,构成一个完整的外控像素点。
4、内置信号整形电路,任何一个像素点收到信号后经过波形整形再输出,保证线路波形畸变不会累加。
5、内置上电复位和掉电复位电路。
6、每个像素点的三基色颜色可实现256级亮度显示,完成16777216种颜色的全真色彩显示,扫描频率不低于400Hz/s。
7、串行级联接口,能通过一根信号线完成数据的接收与解码。
8、任意两点传传输距离在不超过5米时无需增加任何电路。
9、当刷新速率30帧/秒时,级联数不小于1024点。
10、数据发送速度可达800Kbps。
11、光的颜色高度一致,性价比高。
WS2812全彩矩阵LED模块(64位灯珠)
尺寸:6.5*6.5cm
芯片:WS2812B(内置于LED)
LED:5050封装RGB全彩高亮
电压:5V
端口:数字
平台:Arduino 单片机
控制方式:内置控制芯片,只需一个IO口即可控制
电原理图
【花雕动手做】实验四十六:语音控制64位5050 LED模块 ws2812s像素点阵屏
实验开源代码
#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_ws2812.h"
#include "myLib/asr_event.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()
{
digital_write((4),1);
digital_write((21),0);
}
void ASR_CODE()
{
//{ID:500,keyword:"命令词",ASR:"随机点灯",ASRTO:""}
if(snid == 500){
digital_write((21),1);
spi_tft.clear((0xF800));
spi_tft.set_text_color((0xFFFF),(0xF800));
spi_tft.set_cursor(0,50);
spi_tft.draw_hanzi_32("随机点灯");
//{ID:501,keyword:"命令词",ASR:"耍接官",ASRTO:"随机亮灯"}
play_audio(501);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
ASR_WS2812_24.setBrightness(25);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
ASR_WS2812_24.setBrightness(70);
ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
ASR_WS2812_24.pixel_show();
delay(500);
}
//{ID:502,keyword:"命令词",ASR:"反应挺快",ASRTO:"谢谢鼓励"}
if(snid == 502){
}
//{ID:503,keyword:"命令词",ASR:"点亮三个",ASRTO:"语音控制点亮三个灯"}
if(snid == 503){
ASR_WS2812_24.setBrightness(30);
ASR_WS2812_24.pixel_set_color(0,255,0,0);
ASR_WS2812_24.setBrightness(30);
ASR_WS2812_24.pixel_set_color(31,0,255,0);
ASR_WS2812_24.setBrightness(50);
ASR_WS2812_24.pixel_set_color(63,0,0,255);
ASR_WS2812_24.pixel_show();
spi_tft.clear((0x001F));
spi_tft.set_text_color((0xFFFF),(0x001F));
spi_tft.set_cursor(0,30);
spi_tft.draw_hanzi_32("语音控制");
delay(500);
spi_tft.set_cursor(5,70);
spi_tft.draw_hanzi_24("点亮三个灯");
}
//{ID:504,keyword:"命令词",ASR:"点亮五个",ASRTO:"语音控制点亮五个灯"}
if(snid == 504){
ASR_WS2812_24.setBrightness(30);
ASR_WS2812_24.pixel_set_color(14,255,0,0);
ASR_WS2812_24.setBrightness(30);
ASR_WS2812_24.pixel_set_color(23,0,255,0);
ASR_WS2812_24.setBrightness(50);
ASR_WS2812_24.pixel_set_color(60,0,0,255);
ASR_WS2812_24.setBrightness(30);
ASR_WS2812_24.pixel_set_color(45,255,255,0);
ASR_WS2812_24.setBrightness(40);
ASR_WS2812_24.pixel_set_color(3,136,0,255);
ASR_WS2812_24.pixel_show();
spi_tft.clear((0x001F));
spi_tft.set_text_color((0xFFFF),(0x001F));
spi_tft.set_cursor(0,30);
spi_tft.draw_hanzi_32("语音控制");
delay(500);
spi_tft.set_cursor(5,70);
spi_tft.draw_hanzi_24("点亮五个灯");
}
//{ID:505,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
if(snid == 505){
ASR_WS2812_24.pixel_set_all_color(0,0,0);
ASR_WS2812_24.pixel_show();
digital_write((4),0);
digital_write((21),1);
spi_tft.clear((0x07E0));
}
}
void hardware_init(){
spi_tft.init();
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(64);
pinMode(4,output);
pinMode(24,output);
digital_write((4),1);
digital_write((21),0);
vTaskDelete(NULL);
}
void setup()
{
//{speak:方方-标准女声,vol:14,speed:10,platform:haohaodada}
//{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
//{playid:10002,voice:我退下了}
randomSeed(1);
ASR_WS2812_24.pixel_set_all_color(0,0,0);
ASR_WS2812_24.pixel_show();
xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
}
生成模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV1ew411J7d6/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
https://www.bilibili.com/video/BV1ew411J7d6/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
页:
[1]