本例实验采用PT0603光敏三极管
电原理图
产品特性 / PRODUCT FEATURES
封装胶水:无色透明硅胶
外观尺寸(L/W/H):1.6*0.8*0.6mm
焊线材质:金线/合金线
感光峰值波段:850nm
感光范围:400-1050nm
发光角度:120度
EIA规范标准包装
环保产品,符合ROHS标准要求
本例实验的SPI彩色液晶1.77寸显示屏(ST7735驱动)
TFT177-SPI,型号为SX177QQVGA,像素128X160TFT,驱动芯片为ST7735S,这是一款支持SPI接口的1.77寸TFT彩屏,可以显示文字、图形、图片等内容,提高用户互动体验度。
电原理图
【花雕动手做】实验二十九:PT0603光敏三极管检测环境亮度控制ST7735彩屏
实验开源代码
- #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"
-
- uint32_t snid;
- uint16_t liangdu;
- void pins_attached();
- void hardware_init();
-
- SPITFT spi_tft(128, 160);
- WS2812 ASR_WS2812_27(27);
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- void pins_attached(){
- while (1) {
- if((adc_read(17) < 300)){
- delay(200);
- enter_wakeup(3000);
- delay(200);
- spi_tft.clear((0xFFFF));
- spi_tft.set_text_color((0x001F),(0xFFFF));
- spi_tft.set_cursor(0,30);
- spi_tft.draw_hanzi_32("光照度为");
- //{ID:500,keyword:"命令词",ASR:"耍接官",ASRTO:"光照度为"}
- play_audio(500);
- delay(800);
- liangdu = adc_read(17);
- play_num((int64_t)(liangdu * 100), 1);
- spi_tft.set_text_color((0xF800),(0xFFFF));
- spi_tft.set_cursor(35,65);
- spi_tft.set_text_size(32);
- spi_tft.println((String(liangdu)));
- delay(800);
- spi_tft.set_text_color((0x001F),(0xFFFF));
- spi_tft.set_cursor(15,100);
- //{ID:501,keyword:"命令词",ASR:"接耍官",ASRTO:"天黑了,关门睡觉吧"}
- play_audio(501);
- spi_tft.draw_hanzi_24("天黑睡觉");
- delay(7000);
- }
- delay(1);
- }
- vTaskDelete(NULL);
- }
-
- void ASR_CODE()
- {
- //{ID:502,keyword:"唤醒词",ASR:"当前亮度",ASRTO:"开始测量"}
- if(snid == 502){
- digital_write((21),1);
- ASR_WS2812_27.setBrightness(30);
- ASR_WS2812_27.pixel_set_all_color(255,0,0);
- ASR_WS2812_27.pixel_show();
- spi_tft.clear((0x001F));
- spi_tft.set_text_color((0xFFFF),(0x001F));
- delay(800);
- spi_tft.set_cursor(0,40);
- spi_tft.draw_hanzi_32("环境亮度");
- delay(800);
- spi_tft.set_cursor(35,80);
- spi_tft.set_text_size(32);
- liangdu = adc_read(17);
- spi_tft.println((String(liangdu)));
- //{ID:503,keyword:"命令词",ASR:"官耍接",ASRTO:"环境亮度"}
- play_audio(503);
- play_num((int64_t)(liangdu * 100), 1);
- delay(800);
- }
- //{ID:504,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
- if(snid == 504){
- digital_write((21),1);
- ASR_WS2812_27.setBrightness(30);
- ASR_WS2812_27.pixel_set_all_color(0,255,0);
- ASR_WS2812_27.pixel_show();
- spi_tft.clear((0xF800));
- spi_tft.set_text_color((0xFFFF),(0xF800));
- 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:505,keyword:"命令词",ASR:"效果不错",ASRTO:"有你的鼓励真好,谢谢啦!"}
- if(snid == 505){
-
- }
- }
-
- 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_27.pixel_init(3);
- xTaskCreate(pins_attached,"pins_attached",256,NULL,4,NULL);
- vTaskDelete(NULL);
- }
-
- void setup()
- {
- //{speak:小美-娇美女声,vol:20,speed:10,platform:haohaodada}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
- //{playid:10002,voice:我退下了}
-
- //{ID:84,keyword:"命令词",ASR:"条耍改",ASRTO:"零"}
- //{ID:85,keyword:"命令词",ASR:"官接思",ASRTO:"一"}
- //{ID:86,keyword:"命令词",ASR:"痛官松",ASRTO:"二"}
- //{ID:87,keyword:"命令词",ASR:"削丝误",ASRTO:"三"}
- //{ID:88,keyword:"命令词",ASR:"景粮载",ASRTO:"四"}
- //{ID:89,keyword:"命令词",ASR:"博菌避",ASRTO:"五"}
- //{ID:90,keyword:"命令词",ASR:"裁纯碉",ASRTO:"六"}
- //{ID:91,keyword:"命令词",ASR:"插趣悟",ASRTO:"七"}
- //{ID:92,keyword:"命令词",ASR:"辞暖慌",ASRTO:"八"}
- //{ID:93,keyword:"命令词",ASR:"纵猛淡",ASRTO:"九"}
- //{ID:94,keyword:"命令词",ASR:"锦耗暂",ASRTO:"十"}
- //{ID:95,keyword:"命令词",ASR:"燃智截",ASRTO:"百"}
- //{ID:96,keyword:"命令词",ASR:"佛驻延",ASRTO:"千"}
- //{ID:97,keyword:"命令词",ASR:"隔枪绍",ASRTO:"万"}
- //{ID:98,keyword:"命令词",ASR:"惨愤昂",ASRTO:"亿"}
- //{ID:99,keyword:"命令词",ASR:"丙迈扯",ASRTO:"负"}
- //{ID:100,keyword:"命令词",ASR:"铸猜隆",ASRTO:"点"}
- xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
- }
复制代码
训练模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV1jt4y1Z7XS/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
|