37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的。鉴于本人手头积累了一些传感器和执行器模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手试试多做实验,不管成功与否,都会记录下来——小小的进步或是搞不掂的问题,希望能够抛砖引玉。
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验一百九十五:I2C红色8*8LED点阵屏模块 HT16k33(VK16K33)驱动1088BS 物联网可扩展编程
知识点: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显示器/面板的控制及驱动。
【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);
}
Arduino实验场景图
【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);
}
}
Arduino实验场景图
【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;
}
Arduino实验场景图
【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);
}
}
Arduino实验场景图