数码之家
标题:
【Arduino】168种传感器系列实验(207)--- VK16k33 LED8*8点阵I2C
[打印本页]
作者:
eagler8
时间:
2021-9-9 08:55
标题:
【Arduino】168种传感器系列实验(207)--- VK16k33 LED8*8点阵I2C
本帖最后由 eagler8 于 2021-9-9 11:28 编辑
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手试试多做实验,不管成功与否,都会记录下来——小小的进步或是搞不掂的问题,希望能够抛砖引玉。
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块ht16k33驱动1088BS树莓派物联网可扩展编程
[attach]1271569[/attach]
[attach]1271570[/attach]
作者:
习惯孤独
时间:
2021-9-9 09:05
沙发,期待后续
作者:
se7ens
时间:
2021-9-9 09:16
为啥连接器端口都没有看到
作者:
eagler8
时间:
2021-9-9 10:07
习惯孤独 发表于 2021-9-9 09:05
沙发,期待后续
谢谢鼓励
作者:
eagler8
时间:
2021-9-9 10:09
se7ens 发表于 2021-9-9 09:16
为啥连接器端口都没有看到
:lol:挺特殊的接口
[attach]1271604[/attach]
作者:
eagler8
时间:
2021-9-9 11:14
Arduino 系列传感器和执行器模块实验目录清单:
【花雕动手做】用快餐盒盖搭建极低成本的多种运动方式实验平台/机器人
https://www.mydigit.cn/thread-227134-1-1.html
【花雕动手做】超低成本,尝试做个五十元的麦克纳姆轮小车!
https://www.mydigit.cn/thread-220131-1-1.html
【花雕动手做】太搞笑啦,一支胶管制成二只蠕动机器人
https://www.mydigit.cn/thread-226476-1-1.html
【花雕动手做】超迷你哦,用徽商香烟盒做个智能小车!
https://www.mydigit.cn/thread-222085-1-1.html
【花雕动手做】五花八门的简易机器人66种
https://www.mydigit.cn/thread-221775-1-1.html
【花雕动手做】特别苗条,使用微波人体感应模块控制的纤细机器人小车
https://www.mydigit.cn/forum.php?mod=viewthread&tid=244463
素人学习Aduino编程的简单办法
https://www.mydigit.cn/forum.php?mod=viewthread&tid=34316
Arduino 语法手册的五个版本
https://www.mydigit.cn/thread-35089-1-1.html
ESP8266 Arduino开发环境搭建的五个备选地址
https://www.mydigit.cn/thread-40541-1-1.html
只用一块扩展板完成Arduino的9类37项实验(代码+图形+仿真)
https://www.mydigit.cn/thread-44343-1-1.html
37种传感器实验(Arduino)记录每一次小小的进步
https://www.mydigit.cn/thread-35315-1-1.html
实验一百一十五: 震动马达模块 高低电平振动小电机 智能可穿戴式产品震动提醒模块
https://www.mydigit.cn/thread-76804-1-1.html
实验一百一十六:NRF24L01+ 无线模块 功率加强版 2.4G无线收发通信模块 黑金刚
https://www.mydigit.cn/thread-76843-1-1.html
实验一百一十七:蓝色诺基亚5110屏 LCD液晶屏模块 兼容3310 LCD
https://www.mydigit.cn/thread-77142-1-1.html
实验一百一十八:US-015 高分辨超声波测距模块 超声波传感器 US-020升级版
https://www.mydigit.cn/thread-77594-1-1.html
实验一百一十九:HB100微波雷达感应模块 10.525GHz多普勒探测器探头传感器
https://www.mydigit.cn/thread-78082-1-1.html
实验一百二十: SIM800L GPRS 转接板GSM模块 microSIM卡带天线4频通讯模块
https://www.mydigit.cn/thread-75498-1-1.html
实验一百二十一:五向导航按键模块 5D摇杆 单片机 独立键盘开关 按钮 Your Cee
https://www.mydigit.cn/thread-78274-1-1.html
实验一百二十二: BBC microbit micro:bit,bit go,bit club python图形编程开发板
https://www.mydigit.cn/thread-76145-1-1.html
实验一百二十三: P10单红V706模组 32*16单元板LED显示屏
https://www.mydigit.cn/thread-78460-1-1.html
实验一百二十四: PS2鼠标 键盘插座接口 PS2模块
https://www.mydigit.cn/thread-78589-1-1.html
实验一百二十五: 升级版 WeMos D1 R2 WiFi UNO 开发板 基于ESP8266
https://www.mydigit.cn/thread-78843-1-1.html
实验一百二十六:JQ6500语音模块 MP3模块 MCU串口控制播报 一对一5路控制 音乐IC
https://www.mydigit.cn/thread-79043-1-1.html
实验一百二十七:JoyStick Shield PS2游戏摇杆扩展板 模拟键盘鼠标功能 大摇杆
https://www.mydigit.cn/thread-79290-1-1.html
实验一百二十八:日本夏普SHARP PM2.5 灰尘/粉尘传感器 GP2Y1014AU0F 带线
https://www.mydigit.cn/thread-79385-1-1.html
实验一百二十九:GY-302 数字量光强度检测 光照传感器 BH1750FVI 光线检测模块
https://www.mydigit.cn/thread-79661-1-1.html
实验一百三十:XD-203多功能扩展板Multi-function Shield模块(12合1版)
https://www.mydigit.cn/thread-79777-1-1.html
实验一百三十一:24位 WS2812 5050 RGB LED 内置全彩驱动彩灯 圆形开发板
https://www.mydigit.cn/thread-80667-1-1.html
实验一百三十二:WT588D语音模块 语音芯片 可反复擦写高音质语音下载16P-16M 蓝板HW-708
https://www.mydigit.cn/thread-81018-1-1.html
实验一百三十三:夏普GP2Y0A02YK0F 红外测距传感器模块 20-150cm 距离传感器
https://www.mydigit.cn/thread-81360-1-1.html
实验一百三十四:2004A液晶屏 20X4 J204A字符显示液晶模块 204A LCD/LCM 蓝屏5V(带背光 IIC/I2C)
https://www.mydigit.cn/thread-81914-1-1.html
实验一百三十五:ESP8266机智云开发板 ESP12F wifi模块(支持云端的智能硬件开发套件)
https://www.mydigit.cn/thread-82229-1-1.html
实验一百三十六:基于STM32F103RCT6及多种传感器的UFUN2.0升级开发板
https://www.mydigit.cn/thread-100457-1-1.html
实验一百三十七:IIC I2C电平转换模块 5-3v系统兼容 2路
https://www.mydigit.cn/thread-121468-1-1.html
实验一百三十八:中文TTS文本转语音合成模块 替代SYN6288和XFS5152
https://www.mydigit.cn/thread-121781-1-1.html
实验一百三十九:电流互感器模块 5A量程 单相 交流电流传感器模块
https://www.mydigit.cn/thread-122217-1-1.html
实验一百四十:YL-004老款20按键独立键盘 跑马灯矩阵键盘模块
(4*4矩阵键盘+4位独立按键+8位跑马灯组合模块)
https://www.mydigit.cn/thread-122307-1-1.html
实验一百四十一:KY-027 魔术光杯 for UNO 魔术光环模块
https://www.mydigit.cn/thread-122579-1-1.html
实验一百四十二:LCD1602 字符液晶屏 输入输出扩展板 LCD Keypad Shield
https://www.mydigit.cn/thread-123105-1-1.html
实验一百四十三:I2C接口I/O扩展模块 支持级联PCF8574T模块
https://www.mydigit.cn/thread-127953-1-1.html
实验一百四十四:Ethernet W5100S 网络扩展板 SD卡扩展模块 支持MEGA
https://www.mydigit.cn/thread-130504-1-1.html
实验一百四十五:0.91寸OLED液晶屏显示模块 IIC 12832液晶屏 兼容3.3v-5V
https://www.mydigit.cn/thread-124905-1-1.html
实验一百四十六:MT8870 DTMF语音解码板模块 电话拨号控制音频解码处理电路
https://www.mydigit.cn/thread-128475-1-1.html
实验一百四十七:64位 WS2812B 8x8 RGB 5050 LED模块 ws2812s像素点阵屏
https://www.mydigit.cn/thread-127681-1-1.html
实验一百四十八:E18-D80NK 漫反射式红外光电开关避障传感器模块
https://www.mydigit.cn/thread-126831-1-1.html
实验一百四十九:MAX3232电平转TTL电平转换板 mini RS232 MCU串口转换模块
https://www.mydigit.cn/thread-126424-1-1.html
实验一百五十:AS608光学指纹识别模块 智能锁/考勤门禁开发/指纹采集模块
https://www.mydigit.cn/thread-124272-1-1.html
实验一百五十一:ESP-32掌控板 盛思 MicroPython微控制器开发板
https://www.mydigit.cn/thread-136590-1-1.html
实验一百五十二:GY-25 串口直接输出角度数据 倾斜度角度传感器模块 MPU-6050
https://www.mydigit.cn/thread-218333-1-1.html
实验一百五十三:Maixduino AI开发板 k210 RISC-V AI+lOT ESP32视觉听觉开发套装
https://www.mydigit.cn/thread-129551-1-1.html
实验一百五十四:ML8511紫外线传感器模块 模拟量输出UV Sensor Breakou
https://www.mydigit.cn/thread-143285-1-1.html
实验一百五十五:KA2284 电平指示模块 5点LED电量/音频音乐旋律显示器
https://www.mydigit.cn/thread-223567-1-1.html
实验一百五十六:恒压型LED无级触摸调光PWM控制板 电容式触摸开关器模块
https://www.mydigit.cn/thread-223681-1-1.html
实验一百五十七:SG3525 PWM控制器模块 频率可调 占空比可调 波形发生器
https://www.mydigit.cn/thread-129257-1-1.html
实验一百五十八:QMC5883L电子指南针罗盘模块 三轴磁场传感器GY-271
https://www.mydigit.cn/thread-230781-1-1.html
实验一百五十九:MAX9814麦克风放大器模块 MIC话筒声音放大/咪头传感器 CMA-4544PF-W
https://www.mydigit.cn/thread-129060-1-1.html
实验一百六十二:S12SD紫外线传感器模块太阳光强度检测传感器模块高灵敏LM358放大
https://www.mydigit.cn/thread-143194-1-1.html
实验一百六十四:Seeeduino Lotus开发板 传感器9件套 主板+扩展板二合一
https://www.mydigit.cn/thread-141403-1-1.html
实验一百七十:L293D四路电机驱动模块 扩展板 motor control shield 马达板
https://www.mydigit.cn/thread-205585-1-1.html
实验一百七十一:HLK-V20 AI智能离线语音识别模块 150条本地指令离线识别
https://www.mydigit.cn/thread-206726-1-1.html
实验一百七十二:MX1508 四通道双路有刷直流马达驱动模块 2路直流电机驱动模块 双H桥步进电机 正反转PWM调速
https://www.mydigit.cn/thread-216710-1-1.html
实验一百七十三:2262/2272四路无线遥控套件 M4非锁接收板 四键无线遥控器发射模块
https://www.mydigit.cn/thread-224877-1-1.html
实验一百七十四:DRV8833 电机驱动板模块 小体积高性能 2路直流电机驱动板 自平衡小车 代替TB6612FNG
https://www.mydigit.cn/thread-220662-1-1.html
实验一百七十五:LD3320 语音识别模块 非特定人声 语音控制 智能家居开发板
https://www.mydigit.cn/thread-225247-1-1.html
实验二百零七:I2C红色8*8LED点阵模块ht16k33驱动1088BS树莓派物联网可扩展编程
https://www.mydigit.cn/thread-274979-1-1.html
作者:
eagler8
时间:
2021-9-9 11:17
查看模块的驱动芯片
[attach]1271722[/attach]
作者:
eagler8
时间:
2021-9-9 11:29
本帖最后由 eagler8 于 2021-9-9 12:55 编辑
[attach]1271726[/attach]
VK16K33 是一款存储器映射和多功能LED控制驱动芯片。该芯片支持更大 128 点的显示模式(16SEGs×8COMs) 以及更大 13×3 的按键矩阵扫描电路。VK16K33 的软件配置特性使其适用于多种 LED 应用,包括 LED 模块和显示子系统。VK16K33 通过双向I2C 接口可与大多数微控制器进行通信。
功能特点1.工作电压:4.5V~5.5V2.内部 RC 振荡器3.I2C 总线接口4.16×8 位 RAM 用于存储显示数据5.更大显示模式为16×8:16SEGs和8COMs6.读 /写地址自动递增7.多达13×3 按键矩阵扫描功能8. 16阶调光电路9.封装类型:20/24/28-pin SOP VK16K33此系列IC具有低功耗、高抗杂讯及高系统ESD防护能力;VK16K33整合了LED驱动和按键扫描的功能,将控制面板所需要的功能融合于一身,可降低主MCU的负担及需要的I/O数目。采用I2C的介面更可减少控制面板和主板之间的材料成本、进而降低产品整体成本。
VK16K33有28SOP、24SOP和20SOP三种包装,分别对应三种更大显示点数;16x8点LED和13x3个按键、12x8点LED和10x3个按键,以及8x8点LED和8x3个按键。内建显示记忆体及RC振荡电路;工作电压:4.5V~5.5V;VK16K33支持中断信号和轮询两种工作模式。可选择性的提供按键中断信号给MCU,MCU可不须一直检查按键状态。VK16K33与系统控制晶片的传输只需2根信号线,通过VK16K33 侦测按键输入,可减少主版MCU I/O数目及精简主版及面板的布局线路;因此可降低产品整体成本。 VK16K33适用于家电、影音设备、仪表设备、车用装置等LED显示器/面板的控制及驱动。
作者:
eagler8
时间:
2021-9-9 11:51
VK16K33参数特点
工作电压:4.5V-5.5V
集成RC振荡器
I2C总线接口
16×8位RAM用于显示数据存储
最高 16×8模式,16段和8个共同点
读/写地址自动递增
最高 13×3矩阵键扫描
16级调光电路
20/24/28引脚SOP封装类型
VK16K33主要应用
工控指标
数字时钟、温度计、计数器、万用表
组合套装
录像机
仪表读数
其他消费类应用
LED显示屏
[attach]1271764[/attach]
作者:
eagler8
时间:
2021-9-9 12:21
VK16K33功能框图
[attach]1271816[/attach]
作者:
eagler8
时间:
2021-9-9 12:27
VK16K33近似内部连接图
[attach]1271818[/attach]
作者:
eagler8
时间:
2021-9-9 12:28
VK16K33管脚
[attach]1271819[/attach]
作者:
eagler8
时间:
2021-9-9 12:29
[attach]1271820[/attach]
VK16k33芯片详细资料
https://cdn-shop.adafruit.com/datasheets/ht16K33v110.pdf
作者:
eagler8
时间:
2021-9-9 13:09
1088BS共阳点阵屏
[attach]1271838[/attach]
[attach]1271837[/attach]
作者:
eagler8
时间:
2021-9-9 13:10
[attach]1271839[/attach]
作者:
eagler8
时间:
2021-9-9 13:16
[attach]1271841[/attach]
I2C88单色点阵模块,采用VK16K33芯片作为驱动,可以仅仅使用2个IO管脚就能驱动点亮 I2C点阵模块,可以与Arduino或者其他单片机级联使用。
电源要求:+4.5-5.5V
输入类型:数字信号
接口模式:XH2.54×4
引脚定义:G-地 V-电源 D(SDA)-串行数据 C(SCL)-串行时钟
模块重量:35g
作者:
eagler8
时间:
2021-9-9 14:55
I2C红色8*8LED点阵模块VK16k33驱动,参考电原理图
[attach]1271867[/attach]
作者:
eagler8
时间:
2021-9-9 15:00
连线方法:按照传感器模块接口标号与主控制器相连接,标号“G”接主控制器的“地”、“V”接“电源”、“D”接“Arduino UNO R3”SDA,“C”接“Arduino UNO R3”SCL
[attach]1271872[/attach]
作者:
eagler8
时间:
2021-9-9 15:01
[attach]1271876[/attach]
作者:
eagler8
时间:
2021-9-9 15:02
[attach]1271878[/attach]
作者:
eagler8
时间:
2021-9-9 16:38
本帖最后由 eagler8 于 2021-9-9 17:47 编辑
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之一:8x8 LED 矩阵测试,显示一个点
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之一:8x8 LED 矩阵测试,显示一个点
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// For I2C
#include <Wire.h>
// Libraries for Matrix
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
// Good idea to send data to both
// device and serial as it helps with
// troubleshooting.
Serial.println("8x8 LED 矩阵测试");
// set the address
matrix.begin(0x70);
}
void loop() {
// clear display
matrix.clear();
// set pixel x,y to ON
matrix.drawPixel(0, 0, LED_ON);
// write RAM to matrix
matrix.writeDisplay();
delay(500);
}
复制代码
作者:
eagler8
时间:
2021-9-9 16:39
本帖最后由 eagler8 于 2021-9-9 17:50 编辑
实验串口返回情况
[attach]1271957[/attach]
作者:
eagler8
时间:
2021-9-9 16:41
本帖最后由 eagler8 于 2021-9-9 17:50 编辑
实验场景图
[attach]1271958[/attach]
作者:
eagler8
时间:
2021-9-9 16:58
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之二:流水瀑布,循环显示
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之二:流水瀑布,循环显示
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// 引用I2C库
#include <Wire.h>
// 引用ht16k33库
#include "ht16k33.h"
// LED Matrix 模块默认地址为:0x70
#define I2C_ADDR 0x70
HT16K33 *led = NULL; // 申明模块变量
void setup() {
// 初始化I2C, 也可以使用TwoWire
Wire.begin();
// 初始化串口
Serial.begin(115200);
while (led == NULL) {
// 当led没有实例化,就循环检测模块是否连接
Wire.beginTransmission(I2C_ADDR);
uint8_t error = Wire.endTransmission();
if (error == 0) {
Serial.print("LED Matrix module is found at address 0x");
Serial.println(I2C_ADDR, HEX);
led = new HT16K33(I2C_ADDR);
}
delay(2000);
}
// 打开模块
led->displayOn();
}
void loop() {
if (led != NULL) {
// 清除模块所有显示
led->clear();
// 每次需要刷新模块显示,都需要调用write方法将数据传递给模块
led->write();
// 瀑布demo
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
led->setPixel(i, j, 1);
led->write();
delay(30);
}
}
}
delay(2000);
}
复制代码
作者:
eagler8
时间:
2021-9-9 17:07
实验场景图 动态图
作者:
eagler8
时间:
2021-9-9 18:00
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之三:8x8 LED 矩阵测试,显示“T”
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之三:8x8 LED 矩阵测试,显示“T”
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// For I2C
#include <Wire.h>
// Libraries for Matrix
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
// Good idea to send data to both
// device and serial as it helps with
// troubleshooting.
Serial.println("8x8 LED 矩阵测试");
// set the address
matrix.begin(0x70);
}
void loop() {
// Make sure where led 0x0 is:
// And it is working
matrix.setTextSize(1);
matrix.setTextColor(LED_ON);
// clear the matrix
matrix.clear();
// position the cursor
matrix.setCursor(2, 0);
// text to print
matrix.print("T");
Serial.println("显示‘T’");
// write the data out to the matrix
matrix.writeDisplay();
// how fast the characters are displayed
delay(1000);
}
复制代码
作者:
eagler8
时间:
2021-9-9 18:02
实验串口返回情况
[attach]1271969[/attach]
作者:
eagler8
时间:
2021-9-9 18:04
实验场景图
[attach]1271970[/attach]
作者:
eagler8
时间:
2021-9-9 18:32
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之四:8x8 LED 矩阵测试,显示一斜线
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之四:8x8 LED 矩阵测试,显示一斜线
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// For I2C
#include <Wire.h>
// Libraries for Matrix
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
// Good idea to send data to both
// device and serial as it helps with
// troubleshooting.
Serial.println("8x8 LED 矩阵测试");
// set the address
matrix.begin(0x70);
}
void loop() {
// clear display
matrix.clear();
// set (start pixel x,y end pixel, ON)
matrix.drawLine(1,0, 8,7, LED_ON);
// write RAM to matrix
matrix.writeDisplay();
delay(500);
}
复制代码
作者:
eagler8
时间:
2021-9-9 18:35
实验场景图
[attach]1272024[/attach]
作者:
eagler8
时间:
2021-9-9 21:00
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之五:8x8 LED 矩阵测试,显示正方形
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之五:8x8 LED 矩阵测试,显示正方形
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// For I2C
#include <Wire.h>
// Libraries for Matrix
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
// Good idea to send data to both
// device and serial as it helps with
// troubleshooting.
Serial.println("8x8 LED 矩阵测试");
// set the address
matrix.begin(0x70);
}
void loop() {
// clear display
matrix.clear();
// draw a retangle around the outer edge
// of the display
matrix.drawRect(1,0, 7,8, LED_ON);
// uncomment below
// will draw a rectangle arond the edge and
// fill it in, ie. turn on all of the LEDs
//matrix.fillRect(0,0, 8,8, LED_ON);
// write the changes to the display
matrix.writeDisplay();
delay(500);
}
复制代码
作者:
eagler8
时间:
2021-9-9 21:08
实验场景图
[attach]1272239[/attach]
作者:
eagler8
时间:
2021-9-10 07:13
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之六:滚动的一串字母
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之六:滚动的一串字母
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
Serial.println("8x8 LED Matrix Test");
// pass in the address
matrix.begin(0x70);
}
void loop() {
// scroll some text across the matrix
matrix.setTextSize(1);
// Set wrap to false for smooth scrollling
matrix.setTextWrap(false);
matrix.setTextColor(LED_ON);
for (int8_t x = 0; x >= -36; x--) {
matrix.clear();
matrix.setCursor(x, 0);
matrix.print("WoW MoM");
matrix.writeDisplay();
delay(100);
}
}
复制代码
作者:
eagler8
时间:
2021-9-10 07:30
实验场景图 动态图
作者:
eagler8
时间:
2021-9-10 07:48
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之七:流动的斜线
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之七:流动的斜线
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#ifndef _BV
#define _BV(bit) (1<<(bit))
#endif
Adafruit_LEDBackpack matrix = Adafruit_LEDBackpack();
uint8_t counter = 0;
void setup() {
Serial.begin(9600);
Serial.println("VK16K33 test");
matrix.begin(0x70); // pass in the address
}
void loop() {
// paint one LED per row. The HT16K33 internal memory looks like
// a 8x16 bit matrix (8 rows, 16 columns)
for (uint8_t i=0; i<8; i++) {
// draw a diagonal row of pixels
matrix.displaybuffer[i] = _BV((counter+i) % 16) | _BV((counter+i+8) % 16) ;
}
// write the changes we just made to the display
matrix.writeDisplay();
delay(100);
counter++;
if (counter >= 16) counter = 0;
}
复制代码
作者:
eagler8
时间:
2021-9-10 08:35
本帖最后由 eagler8 于 2021-9-10 08:37 编辑
实验场景图 动态图
作者:
eagler8
时间:
2021-9-10 10:50
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之八:右向流动显示“SOS Call 9-1-1”
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之八:右向流动显示“SOS Call 9-1-1”
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h" //necessary
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
matrix.begin(0x70); // pass in the address
}
static const uint8_t PROGMEM // Setting Static Constants for the LED Matrix
S_bmp[] = // Declaring the "S" Shape Bitmap for the Matrix
{ B01111111, // String of characters dictates each LED position as on or off on 8x8 gird
B01111111, // 0 = Off LED 1 = On LED
B01100000,
B01111110,
B01111110,
B00000110,
B11111110,
B11111110 },
O_bmp[] = // Declaring the "O" Shape Bitmap for the Matrix
{ B11111111,
B11111111,
B11000011,
B11000011,
B11000011,
B11000011,
B11111111,
B11111111 },
S2_bmp[] = // Declaring the second "S" Shape Bitmap for the Matrix
{ B01111111,
B01111111,
B01110000,
B01111110,
B01111110,
B00000110,
B11111110,
B11111110 };
void loop() {
matrix.clear(); // Starting with clear matrix where all LEDs are off
matrix.drawBitmap(1, 0, S_bmp, 8, 8, LED_ON); // Drawing the "S" Bitmap according to void setup configuration
matrix.writeDisplay(); // With 2000 milisecond delay
delay(2000);
matrix.clear(); // Transitioning with clear matrix where all LEDs are off
matrix.drawBitmap(1, 0, O_bmp, 7, 8, LED_ON); // Drawing the "O" Bitmap according to void setup configuration
matrix.writeDisplay(); // With 2000 milisecond delay
delay(2000);
matrix.clear(); // Transitioning with clear matrix where all LEDs are off
matrix.drawBitmap(1, 0, S2_bmp, 7, 8, LED_ON); // Drawing the second "S" Bitmap according to void setup configuration
matrix.writeDisplay(); // With 2000 milisecond delay
delay(2000);
matrix.setTextSize(1); // Setting matrix text size to 1
matrix.setTextWrap(false); // Preventing text wrapping to scroll text continuously through matrix
matrix.setTextColor(LED_ON); // Turning LED On
for (int8_t x=0; x>=-36; x--) { // Setting for loop to position letters side by side for the scroll
matrix.clear(); // Transitioning with clear matrix where all LEDs are off
matrix.setCursor(x,0); // Defining letter positions to print one at time side by side
matrix.print(" Call"); // Printing "Call" on the matrix
matrix.writeDisplay(); // With 100 milisecond delay
delay(100);
}
matrix.setRotation(0); // Prevent rotation and keep scroll at the same angle
for (int8_t x=7; x>=-36; x--) { // Setting new for loop to position letters side by side for the scroll
matrix.clear(); // Transitioning with clear matrix where all LEDs are off
matrix.setCursor(x,0); // Defining letter positions to print one at time side by side
matrix.print("9-1-1"); // Printing "9-1-1" on the matrix
matrix.writeDisplay(); // With 100 milisecond delay
delay(100);
}
}
复制代码
作者:
eagler8
时间:
2021-9-10 11:14
实验场景图 动态图
https://imagemc.dfrobot.com.cn/d ... cslknczsddmxkxa.gif
作者:
eagler8
时间:
2021-9-10 11:50
刚搜到的模块电原理参考图与实验图
[attach]1272720[/attach]
作者:
eagler8
时间:
2021-9-10 11:50
[attach]1272721[/attach]
作者:
eagler8
时间:
2021-9-10 13:17
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之九:循环显示垂直条
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之九:循环显示垂直条
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
Matrix_8x8 matrix;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
}
void loop() {
for (int i = 0; i < 33; i++) {
// writeBar的输入范围是[0-32]
matrix.writeBar(i);
matrix.display();
delay(150);
}
}
复制代码
作者:
eagler8
时间:
2021-9-10 13:27
实验场景图 动态图
作者:
eagler8
时间:
2021-9-10 16:14
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之十:显示12个自定义图片
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之十:显示12个自定义图片
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
// 创建 uint64_t 类型的 8x8 矩阵图片在如下网址
// https://xantorohara.github.io/led-matrix-editor/#
const uint64_t EXAMPLE[12] = {
0x5554545050404000,
0x3f21212121212121,
0x3f212d2121212121,
0x3f212d212d212121,
0x3f212d212d212d21,
0x3f212d2d2d212121,
0x3f212d2d2d2d2d2d,
0x00040a1120408000,
0x081c3e7f1c1c1c1c,
0x0010307fff7f3010,
0x1c1c1c1c7f3e1c08,
0x00080cfefffe0c08
};
Matrix_8x8 matrix;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
}
void loop() {
matrix.writeOnePicture(EXAMPLE[11]);
matrix.display();
delay(500);
matrix.writePictures(EXAMPLE, 12, 1000, ACTION_SCROLLING);
matrix.display();
}
复制代码
作者:
eagler8
时间:
2021-9-10 16:40
实验场景图 动态图
作者:
eagler8
时间:
2021-9-10 16:42
实验场景图 动态图之二
作者:
eagler8
时间:
2021-9-11 07:47
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十一:滚动的小球
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十一:滚动的小球
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_24bargraph bar = Adafruit_24bargraph();
void setup() {
Serial.begin(9600);
Serial.println("HT16K33 Bi-Color Bargraph test");
bar.begin(0x70); // pass in the address
for (uint8_t b=0; b<24; b++ ){
if ((b % 3) == 0) bar.setBar(b, LED_RED);
if ((b % 3) == 1) bar.setBar(b, LED_YELLOW);
if ((b % 3) == 2) bar.setBar(b, LED_GREEN);
}
bar.writeDisplay();
delay(2000);
}
void loop() {
for (uint8_t b=0; b<24; b++) {
bar.setBar(b, LED_RED);
bar.writeDisplay();
delay(50);
bar.setBar(b, LED_OFF);
bar.writeDisplay();
}
for (uint8_t b=0; b<24; b++) {
bar.setBar(b, LED_GREEN);
bar.writeDisplay();
delay(50);
bar.setBar(b, LED_OFF);
bar.writeDisplay();
}
for (uint8_t b=0; b<24; b++) {
bar.setBar(36-b, LED_YELLOW);
bar.writeDisplay();
delay(50);
bar.setBar(42-b, LED_OFF);
bar.writeDisplay();
}
}
复制代码
作者:
eagler8
时间:
2021-9-11 08:00
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 08:42
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十二:不断变换的符号图形
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十二:不断变换的符号图形
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
Matrix_8x8 matrix;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
}
void loop() {
for (int i = 0; i < 29; i++) {
// The input range of writeIcon is [0-28]
matrix.writeIcon(i);
matrix.display();
delay(200);
}
}
复制代码
作者:
eagler8
时间:
2021-9-11 08:53
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 09:05
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十三:流动的字母"abc","efg"
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十三:流动的字母"abc","efg"
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
Matrix_8x8 matrix;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
}
void loop() {
matrix.writeString("!", 500, ACTION_SHIFT);
matrix.display();
matrix.writeString("abc", 500, ACTION_SHIFT);
matrix.display();
matrix.writeString("efg", 500, ACTION_SCROLLING);
matrix.display();
}
复制代码
作者:
eagler8
时间:
2021-9-11 09:10
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 09:16
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十四:不断落下的音乐符
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十四:不断落下的音乐符
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
Matrix_8x8 matrix;
int temp = -8;
uint8_t orientation = DISPLAY_ROTATE_0;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
matrix.writeIcon(21);
}
void loop() {
matrix.display();
delay(100);
// Activate after call display()
matrix.setDisplayOffset(temp, temp);
temp++;
if (temp == 9) {
temp = -8;
orientation = orientation + 1;
if (orientation == 4) {
orientation = DISPLAY_ROTATE_0;
}
// Activate after call writeXXX
matrix.setDisplayOrientation(orientation);
matrix.writeIcon(21);
}
}
复制代码
作者:
eagler8
时间:
2021-9-11 09:22
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 09:51
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十五:不同方向的滚动字符串
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十五:不同方向的滚动字符串
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
Serial.println("8x8 LED Matrix Test");
matrix.begin(0x70); // pass in the address
}
static const uint8_t PROGMEM
smile_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
},
neutral_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10111101,
B10000001,
B01000010,
B00111100
},
frown_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01000010,
B00111100
};
void loop() {
matrix.clear();
matrix.drawBitmap(1, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(1, 0, neutral_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
delay(200);
matrix.clear();
matrix.drawBitmap(1, 0, frown_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
delay(200);
matrix.clear(); // clear display
matrix.drawPixel(1, 0, LED_ON);
matrix.writeDisplay(); // write the changes we just made to the display
delay(200);
matrix.clear();
matrix.drawLine(1, 0, 7, 7, LED_ON);
matrix.writeDisplay(); // write the changes we just made to the display
delay(200);
matrix.clear();
matrix.drawRect(1, 0, 8, 8, LED_ON);
matrix.fillRect(2, 2, 4, 4, LED_ON);
matrix.writeDisplay(); // write the changes we just made to the display
delay(200);
matrix.clear();
matrix.drawCircle(3, 3, 3, LED_ON);
matrix.writeDisplay(); // write the changes we just made to the display
delay(200);
matrix.setTextSize(1);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x = 0; x >= -36; x--) {
matrix.clear();
matrix.setCursor(x, 0);
matrix.print("Hello");
matrix.writeDisplay();
delay(50);
}
matrix.setRotation(3);
for (int8_t x = 7; x >= -36; x--) {
matrix.clear();
matrix.setCursor(x, 0);
matrix.print("World");
matrix.writeDisplay();
delay(50);
}
matrix.setRotation(0);
}
复制代码
作者:
eagler8
时间:
2021-9-11 09:59
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 10:15
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十六:滚动的一串数字
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十六:滚动的一串数字
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include "Grove_LED_Matrix_Driver_HT16K33.h"
Matrix_8x8 matrix;
void setup() {
Wire.begin();
matrix.init();
matrix.setBrightness(0);
matrix.setBlinkRate(BLINK_OFF);
}
void loop() {
// 显示数字“0”并延迟 400ns
matrix.writeNumber(0, 400);
matrix.display();
// 显示数字 "-2147483648" 并延迟 (300*11)ns
// writeNumber()的显示范围是int32_t(从-2147483648到2147483647)
matrix.writeNumber(-2147483648, 300);
matrix.display();
}
复制代码
作者:
eagler8
时间:
2021-9-11 10:18
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 10:35
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十七:变换的笑脸与流淌的字符"Hello","World"
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十七:变换的笑脸与流淌的字符"Hello","World"
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
void setup() {
Serial.begin(9600);
Serial.println("8x8 LED Matrix Test");
matrix.begin(0x70); // pass in the address
}
static const uint8_t PROGMEM
smile_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
},
neutral_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10111101,
B10000001,
B01000010,
B00111100
},
frown_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01000010,
B00111100
};
void loop() {
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_GREEN);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_GREEN);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_GREEN);
matrix.writeDisplay();
delay(500);
matrix.clear(); // clear display
matrix.drawPixel(0, 0, LED_GREEN);
matrix.writeDisplay(); // write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawLine(0, 0, 7, 7, LED_GREEN);
matrix.writeDisplay(); // write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawRect(0, 0, 8, 8, LED_GREEN);
matrix.fillRect(2, 2, 4, 4, LED_GREEN);
matrix.writeDisplay(); // write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawCircle(3, 3, 3, LED_GREEN);
matrix.writeDisplay(); // write the changes we just made to the display
delay(500);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_GREEN);
for (int8_t x = 7; x >= -36; x--) {
matrix.clear();
matrix.setCursor(x, 0);
matrix.print("Hello");
matrix.writeDisplay();
delay(50);
}
matrix.setRotation(3);
matrix.setTextColor(LED_GREEN);
for (int8_t x = 7; x >= -36; x--) {
matrix.clear();
matrix.setCursor(x, 0);
matrix.print("World");
matrix.writeDisplay();
delay(50);
}
matrix.setRotation(0);
}
复制代码
作者:
eagler8
时间:
2021-9-11 11:03
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 11:09
实验场景图 动态图之二
https://imagemc.dfrobot.com.cn/data/attachment/forum/202109/11/110720r68sy9nn9yojy86h.gif
作者:
eagler8
时间:
2021-9-11 11:13
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十八:随机的眨眼睛
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十八:随机的眨眼睛
实验接线:
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <WaveHC.h>
#include <WaveUtil.h>
#include "Adafruit_LEDBackpack.h"
// These WAV files should be in the root level of the SD card:
static const char PROGMEM
wav0[] = "beware_i.wav",
wav1[] = "ihunger.wav",
wav2[] = "run_cowd.wav";
static const char * const wavname[] PROGMEM = { wav0, wav1, wav2 };
// PROGMEM makes frequent appearances throughout this code, reason being that
// the SD card library requires gobs of precious RAM (leaving very little to
// our own sketch). PROGMEM lets us put fixed data into program flash memory,
// which is considerably more spacious. String tables are paritcularly nasty.
// See www.arduino.cc/en/Reference/PROGMEM for more info.
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the volumes root directory
FatReader file; // This object represent the WAV file for a phrase
WaveHC wave; // A single wave object -- only one sound is played at a time
// Because the two eye matrices share the same address, only four
// matrix objects are needed for the five displays:
#define MATRIX_EYES 0
#define MATRIX_MOUTH_LEFT 1
#define MATRIX_MOUTH_MIDDLE 2
#define MATRIX_MOUTH_RIGHT 3
Adafruit_8x8matrix matrix[4] = { // Array of Adafruit_8x8matrix objects
Adafruit_8x8matrix(), Adafruit_8x8matrix(),
Adafruit_8x8matrix(), Adafruit_8x8matrix() };
// Rather than assigning matrix addresses sequentially in a loop, each
// has a spot in this array. This makes it easier if you inadvertently
// install one or more matrices in the wrong physical position --
// re-order the addresses in this table and you can still refer to
// matrices by index above, no other code or wiring needs to change.
static const uint8_t PROGMEM matrixAddr[] = { 0x70, 0x71, 0x72, 0x73 };
static const uint8_t PROGMEM // Bitmaps are stored in program memory
blinkImg[][8] = { // Eye animation frames
{ B00111100, // Fully open eye
B01111110,
B11111111,
B11111111,
B11111111,
B11111111,
B01111110,
B00111100 },
{ B00000000,
B01111110,
B11111111,
B11111111,
B11111111,
B11111111,
B01111110,
B00111100 },
{ B00000000,
B00000000,
B00111100,
B11111111,
B11111111,
B11111111,
B00111100,
B00000000 },
{ B00000000,
B00000000,
B00000000,
B00111100,
B11111111,
B01111110,
B00011000,
B00000000 },
{ B00000000, // Fully closed eye
B00000000,
B00000000,
B00000000,
B10000001,
B01111110,
B00000000,
B00000000 } },
mouthImg[][24] = { // Mouth animation frames
{ B00000000, B00000000, B00000000, // Mouth position A
B00000000, B00000000, B00000000,
B01111111, B11111111, B11111110,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000 },
{ B00000000, B00000000, B00000000, // Mouth position B
B00000000, B00000000, B00000000,
B00111111, B11111111, B11111100,
B00000111, B00000000, B11100000,
B00000000, B11111111, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000 },
{ B00000000, B00000000, B00000000, // Mouth position C
B00000000, B00000000, B00000000,
B00111111, B11111111, B11111100,
B00001000, B00000000, B00010000,
B00000110, B00000000, B01100000,
B00000001, B11000011, B10000000,
B00000000, B00111100, B00000000,
B00000000, B00000000, B00000000 },
{ B00000000, B00000000, B00000000, // Mouth position D
B00000000, B00000000, B00000000,
B00111111, B11111111, B11111100,
B00100000, B00000000, B00000100,
B00010000, B00000000, B00001000,
B00001100, B00000000, B00110000,
B00000011, B10000001, B11000000,
B00000000, B01111110, B00000000 },
{ B00000000, B00000000, B00000000, // Mouth position E
B00000000, B00111100, B00000000,
B00011111, B11000011, B11111000,
B00000011, B10000001, B11000000,
B00000000, B01111110, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000 },
{ B00000000, B00111100, B00000000, // Mouth position F
B00000000, B11000011, B00000000,
B00001111, B00000000, B11110000,
B00000001, B00000000, B10000000,
B00000000, B11000011, B00000000,
B00000000, B00111100, B00000000,
B00000000, B00000000, B00000000,
B00000000, B00000000, B00000000 } };
// Animation sequences corresponding to each WAV. First number in
// each pair is a mouth bitmap index. Second number is the hold
// time (in frames). 255 marks end of list.
// There is no 'magic' here, the software is NOT deriving mouth
// position from the sound...the tables were determined by hand,
// just as animators do it. Further explanation here:
// http://www.idleworm.com/how/anm/03t/talk1.shtml
static const uint8_t PROGMEM
seq1[] = { 0, 2, 2, 5, 5, 3, 3, 7, // "Beware, I live!"
4, 5, 3, 4, 2, 5, 4, 3,
3, 4, 1, 5, 3, 5, 255 },
seq2[] = { 0, 1, 3, 5, 1, 5, 4, 2, // "I hunger!"
3, 2, 1, 2, 4, 4, 1, 3,
4, 2, 255 },
seq3[] = { 0, 1, 1, 2, 3, 6, 2, 5, // "Run, coward!"
0, 1, 4, 4, 5, 2, 1, 5,
3, 6, 1, 4, 255 };
static const uint8_t * const anim[] = { seq1, seq2, seq3 };
const uint8_t
blinkIndex[] PROGMEM = { 1, 2, 3, 4, 3, 2, 1 }; // Blink bitmap sequence
uint8_t
blinkCountdown = 100, // Countdown to next blink (in frames)
gazeCountdown = 75, // Countdown to next eye movement
gazeFrames = 50, // Duration of eye movement (smaller = faster)
mouthPos = 0, // Current image number for mouth
mouthCountdown = 10, // Countdown to next mouth change
newPos = 255, // New mouth position for current frame
*seq, // Animation sequence currently being played back
idx, // Current array index within animation sequence
prevBtn = 99, // Button # pressed on last loop() iteration
btnCount = 0; // Number of iterations same button has been held
int8_t
eyeX = 3, eyeY = 3, // Current eye position
newX = 3, newY = 3, // Next eye position
dX = 0, dY = 0; // Distance from prior to new position
void setup() {
Serial.begin(9600);
Serial.println(F("WAV face"));
if(!card.init()) Serial.println(F("Card init. failed!"));
if(!vol.init(card)) Serial.println(F("No partition!"));
if(!root.openRoot(vol)) Serial.println(F("Couldn't open dir"));
Serial.println(F("Files found:"));
root.ls();
// Seed random number generator from an unused analog input:
randomSeed(analogRead(A0));
// Initialize each matrix object:
for(uint8_t i=0; i<4; i++) {
matrix[i].begin(pgm_read_byte(&matrixAddr[i]));
// If using 'small' (1.2") displays vs. 'mini' (0.8"), enable this:
// matrix[i].setRotation(3);
}
// Enable pull-up resistors on three button inputs.
// Other end of each button then connects to GND.
for(uint8_t i=6; i<=8; i++) {
pinMode(i, INPUT);
digitalWrite(i, HIGH); // Enable pullup
}
}
void loop() {
uint8_t i;
// Draw eyeball in current state of blinkyness (no pupil).
matrix[MATRIX_EYES].clear();
matrix[MATRIX_EYES].drawBitmap(0, 0,
blinkImg[
(blinkCountdown < sizeof(blinkIndex)) ? // Currently blinking?
pgm_read_byte(&blinkIndex[blinkCountdown]) : // Yes, look up bitmap #
0 // No, show bitmap 0
], 8, 8, LED_ON);
// Decrement blink counter. At end, set random time for next blink.
if(--blinkCountdown == 0) blinkCountdown = random(5, 180);
if(--gazeCountdown <= gazeFrames) {
// Eyes are in motion - draw pupil at interim position
matrix[MATRIX_EYES].fillRect(
newX - (dX * gazeCountdown / gazeFrames),
newY - (dY * gazeCountdown / gazeFrames),
2, 2, LED_OFF);
if(gazeCountdown == 0) { // Last frame?
eyeX = newX; eyeY = newY; // Yes. What's new is old, then...
do { // Pick random positions until one is within the eye circle
newX = random(7); newY = random(7);
dX = newX - 3; dY = newY - 3;
} while((dX * dX + dY * dY) >= 10); // Thank you Pythagoras
dX = newX - eyeX; // Horizontal distance to move
dY = newY - eyeY; // Vertical distance to move
gazeFrames = random(3, 15); // Duration of eye movement
gazeCountdown = random(gazeFrames, 120); // Count to end of next movement
}
} else {
// Not in motion yet -- draw pupil at current static position
matrix[MATRIX_EYES].fillRect(eyeX, eyeY, 2, 2, LED_OFF);
}
// Scan buttons 6, 7, 8 looking for first button pressed...
for(i=0; (i<3) && (digitalRead(i+6) == HIGH); i++);
if(i < 3) { // Anything pressed? Yes!
if(i == prevBtn) { // Same as last time we checked? Good!
if(++btnCount == 3) { // 3 passes to 'debounce' button input
playfile((char *)pgm_read_word(&wavname[i])); // Start WAV
// Look up animation sequence # corresponding to this WAV...
seq = (uint8_t *)pgm_read_word(&anim[i]);
idx = 0; // Begin at first byte of data
newPos = pgm_read_byte(&seq[idx++]); // Initial mouth pos
mouthCountdown = pgm_read_byte(&seq[idx++]); // Hold time for pos
}
} else btnCount = 0; // Different button than before - start count over
prevBtn = i;
} else prevBtn = 99; // No buttons pressed
if(newPos != 255) { // Is the mouth in motion?
if(--mouthCountdown == 0) { // Count down frames to next position
newPos = pgm_read_byte(&seq[idx++]); // New mouth position
if(newPos == 255) { // End of list?
mouthPos = 0; // Yes, set mouth to neutral position
} else {
mouthPos = newPos; // Set mouth to new position
mouthCountdown = pgm_read_byte(&seq[idx++]); // Read hold time
}
}
} else mouthPos = 0; // Mouth not in motion -- set to neutral position
drawMouth(mouthImg[mouthPos]);
// Refresh all matrices in one quick pass
for(uint8_t i=0; i<4; i++) matrix[i].writeDisplay();
delay(20);
}
// Draw mouth image across three adjacent displays
void drawMouth(const uint8_t *img) {
for(uint8_t i=0; i<3; i++) {
matrix[MATRIX_MOUTH_LEFT + i].clear();
matrix[MATRIX_MOUTH_LEFT + i].drawBitmap(i * -8, 0, img, 24, 8, LED_ON);
}
}
// Open and start playing a WAV file
void playfile(const char *name) {
char filename[13]; // 8.3+NUL
if(wave.isplaying) wave.stop(); // Stop any currently-playing WAV
strcpy_P(filename, name); // Copy name out of PROGMEM into RAM
if(!file.open(root, filename)) {
Serial.print(F("Couldn't open file "));
Serial.println(filename);
return;
}
if(!wave.create(file)) {
Serial.println(F("Not a valid WAV"));
return;
}
wave.play();
}
复制代码
作者:
eagler8
时间:
2021-9-11 11:28
实验场景图 动态图
作者:
eagler8
时间:
2021-9-11 16:18
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十九:Arduino 的小型音频可视化
实验开源代码
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十九:Arduino 的小型音频可视化
模块接线:
- 3.3V 至麦克风放大器 + 和 Arduino AREF 引脚 <-- 重要!
MAX9814 Arduino
VCC 3.3V
GND GND
OUT A0
VK16k33 UNO
VIN 5V
GND GND
SCL A5
SDA A4
*/
// 重要提示:FFT_N 应该在 ffft.h 中 #defined 为 128。
#include <avr/pgmspace.h>
#include <ffft.h>
#include <math.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>
// Microphone connects to Analog Pin 0. Corresponding ADC channel number
// varies among boards...it's ADC0 on Uno and Mega, ADC7 on Leonardo.
// Other boards may require different settings; refer to datasheet.
#ifdef __AVR_ATmega32U4__
#define ADC_CHANNEL 7
#else
#define ADC_CHANNEL 0
#endif
int16_t capture[FFT_N]; // Audio capture buffer
complex_t bfly_buff[FFT_N]; // FFT "butterfly" buffer
uint16_t spectrum[FFT_N / 2]; // Spectrum output buffer
volatile byte samplePos = 0; // Buffer position counter
byte
peak[8], // Peak level of each column; used for falling dots
dotCount = 0, // Frame counter for delaying dot-falling speed
colCount = 0; // Frame counter for storing past column data
int
col[8][10], // Column levels for the prior 10 frames
minLvlAvg[8], // For dynamic adjustment of low & high ends of graph,
maxLvlAvg[8], // pseudo rolling averages for the prior few frames.
colDiv[8]; // Used when filtering FFT output to 8 columns
/*
These tables were arrived at through testing, modeling and trial and error,
exposing the unit to assorted music and sounds. But there's no One Perfect
EQ Setting to Rule Them All, and the graph may respond better to some
inputs than others. The software works at making the graph interesting,
but some columns will always be less lively than others, especially
comparing live speech against ambient music of varying genres.
*/
static const uint8_t PROGMEM
// This is low-level noise that's subtracted from each FFT output column:
noise[64] = { 8, 6, 6, 5, 3, 4, 4, 4, 3, 4, 4, 3, 2, 3, 3, 4,
2, 1, 2, 1, 3, 2, 3, 2, 1, 2, 3, 1, 2, 3, 4, 4,
3, 2, 2, 2, 2, 2, 2, 1, 3, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4
},
// These are scaling quotients for each FFT output column, sort of a
// graphic EQ in reverse. Most music is pretty heavy at the bass end.
eq[64] = {
255, 175, 218, 225, 220, 198, 147, 99, 68, 47, 33, 22, 14, 8, 4, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
// When filtering down to 8 columns, these tables contain indexes
// and weightings of the FFT spectrum output values to use. Not all
// buckets are used -- the bottom-most and several at the top are
// either noisy or out of range or generally not good for a graph.
col0data[] = { 2, 1, // # of spectrum bins to merge, index of first
111, 8
}, // Weights for each bin
col1data[] = { 4, 1, // 4 bins, starting at index 1
19, 186, 38, 2
}, // Weights for 4 bins. Got it now?
col2data[] = { 5, 2,
11, 156, 118, 16, 1
},
col3data[] = { 8, 3,
5, 55, 165, 164, 71, 18, 4, 1
},
col4data[] = { 11, 5,
3, 24, 89, 169, 178, 118, 54, 20, 6, 2, 1
},
col5data[] = { 17, 7,
2, 9, 29, 70, 125, 172, 185, 162, 118, 74,
41, 21, 10, 5, 2, 1, 1
},
col6data[] = { 25, 11,
1, 4, 11, 25, 49, 83, 121, 156, 180, 185,
174, 149, 118, 87, 60, 40, 25, 16, 10, 6,
4, 2, 1, 1, 1
},
col7data[] = { 37, 16,
1, 2, 5, 10, 18, 30, 46, 67, 92, 118,
143, 164, 179, 185, 184, 174, 158, 139, 118, 97,
77, 60, 45, 34, 25, 18, 13, 9, 7, 5,
3, 2, 2, 1, 1, 1, 1
},
// And then this points to the start of the data for each of the columns:
* const colData[] = {
col0data, col1data, col2data, col3data,
col4data, col5data, col6data, col7data
};
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
void setup() {
uint8_t i, j, nBins, binNum, *data;
memset(peak, 0, sizeof(peak));
memset(col , 0, sizeof(col));
for (i = 0; i < 8; i++) {
minLvlAvg[i] = 0;
maxLvlAvg[i] = 512;
data = (uint8_t *)pgm_read_word(&colData[i]);
nBins = pgm_read_byte(&data[0]) + 2;
binNum = pgm_read_byte(&data[1]);
for (colDiv[i] = 0, j = 2; j < nBins; j++)
colDiv[i] += pgm_read_byte(&data[j]);
}
matrix.begin(0x70);
// Init ADC free-run mode; f = ( 16MHz/prescaler ) / 13 cycles/conversion
ADMUX = ADC_CHANNEL; // Channel sel, right-adj, use AREF pin
ADCSRA = _BV(ADEN) | // ADC enable
_BV(ADSC) | // ADC start
_BV(ADATE) | // Auto trigger
_BV(ADIE) | // Interrupt enable
_BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); // 128:1 / 13 = 9615 Hz
ADCSRB = 0; // Free run mode, no high MUX bit
DIDR0 = 1 << ADC_CHANNEL; // Turn off digital input for ADC pin
TIMSK0 = 0; // Timer0 off
sei(); // Enable interrupts
}
void loop() {
uint8_t i, x, L, *data, nBins, binNum, weighting, c;
uint16_t minLvl, maxLvl;
int level, y, sum;
while (ADCSRA & _BV(ADIE)); // Wait for audio sampling to finish
fft_input(capture, bfly_buff); // Samples -> complex #s
samplePos = 0; // Reset sample counter
ADCSRA |= _BV(ADIE); // Resume sampling interrupt
fft_execute(bfly_buff); // Process complex data
fft_output(bfly_buff, spectrum); // Complex -> spectrum
// Remove noise and apply EQ levels
for (x = 0; x < FFT_N / 2; x++) {
L = pgm_read_byte(&noise[x]);
spectrum[x] = (spectrum[x] <= L) ? 0 :
(((spectrum[x] - L) * (256L - pgm_read_byte(&eq[x]))) >> 8);
}
// Fill background w/colors, then idle parts of columns will erase
matrix.fillRect(0, 0, 8, 3, LED_RED); // Upper section
matrix.fillRect(0, 3, 8, 2, LED_YELLOW); // Mid
matrix.fillRect(0, 5, 8, 3, LED_GREEN); // Lower section
// Downsample spectrum output to 8 columns:
for (x = 0; x < 8; x++) {
data = (uint8_t *)pgm_read_word(&colData[x]);
nBins = pgm_read_byte(&data[0]) + 2;
binNum = pgm_read_byte(&data[1]);
for (sum = 0, i = 2; i < nBins; i++)
sum += spectrum[binNum++] * pgm_read_byte(&data[i]); // Weighted
col[x][colCount] = sum / colDiv[x]; // Average
minLvl = maxLvl = col[x][0];
for (i = 1; i < 10; i++) { // Get range of prior 10 frames
if (col[x][i] < minLvl) minLvl = col[x][i];
else if (col[x][i] > maxLvl) maxLvl = col[x][i];
}
// minLvl and maxLvl indicate the extents of the FFT output, used
// for vertically scaling the output graph (so it looks interesting
// regardless of volume level). If they're too close together though
// (e.g. at very low volume levels) the graph becomes super coarse
// and 'jumpy'...so keep some minimum distance between them (this
// also lets the graph go to zero when no sound is playing):
if ((maxLvl - minLvl) < 8) maxLvl = minLvl + 8;
minLvlAvg[x] = (minLvlAvg[x] * 7 + minLvl) >> 3; // Dampen min/max levels
maxLvlAvg[x] = (maxLvlAvg[x] * 7 + maxLvl) >> 3; // (fake rolling average)
// Second fixed-point scale based on dynamic min/max levels:
level = 10L * (col[x][colCount] - minLvlAvg[x]) /
(long)(maxLvlAvg[x] - minLvlAvg[x]);
// Clip output and convert to byte:
if (level < 0L) c = 0;
else if (level > 10) c = 10; // Allow dot to go a couple pixels off top
else c = (uint8_t)level;
if (c > peak[x]) peak[x] = c; // Keep dot on top
if (peak[x] <= 0) { // Empty column?
matrix.drawLine(x, 0, x, 7, LED_OFF);
continue;
} else if (c < 8) { // Partial column?
matrix.drawLine(x, 0, x, 7 - c, LED_OFF);
}
// The 'peak' dot color varies, but doesn't necessarily match
// the three screen regions...yellow has a little extra influence.
y = 8 - peak[x];
if (y < 2) matrix.drawPixel(x, y, LED_RED);
else if (y < 6) matrix.drawPixel(x, y, LED_YELLOW);
else matrix.drawPixel(x, y, LED_GREEN);
}
matrix.writeDisplay();
// Every third frame, make the peak pixels drop by 1:
if (++dotCount >= 3) {
dotCount = 0;
for (x = 0; x < 8; x++) {
if (peak[x] > 0) peak[x]--;
}
}
if (++colCount >= 10) colCount = 0;
}
ISR(ADC_vect) { // Audio-sampling interrupt
static const int16_t noiseThreshold = 4;
int16_t sample = ADC; // 0-1023
capture[samplePos] =
((sample > (512 - noiseThreshold)) &&
(sample < (512 + noiseThreshold))) ? 0 :
sample - 512; // Sign-convert for FFT; -512 to +511
if (++samplePos >= FFT_N) ADCSRA &= ~_BV(ADIE); // Buffer full, interrupt off
}
复制代码
作者:
eagler8
时间:
2021-9-11 16:22
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目十九:Arduino 的小型音频可视化(视频49秒)
https://v.youku.com/v_show/id_XNTgwNTE5NTU0OA==.html?spm=a2hcb.playlsit.page.1
作者:
eagler8
时间:
2021-9-11 16:35
实验场景图 动态图
欢迎光临 数码之家 (https://www.mydigit.cn/)
Powered by Discuz! X3.4