“4位数码管模块”的版本间的差异
来自YFRobotwiki
| 第76行: | 第76行: | ||
[http://yfrobot.gitee.io/lib/YFTM1650.rar TM1650库文件] | [http://yfrobot.gitee.io/lib/YFTM1650.rar TM1650库文件] | ||
<pre > | <pre > | ||
| − | /*-- | + | /* |
| + | 8-segment display driver of YFRobot 4-bit digital tube module based on TM1650 chip | ||
| + | Created by yfrobot,Released into the public domain. | ||
| + | */ | ||
| − | + | #include <YFTM1650.h> | |
| − | + | YFTM1650 YF_4BitDis(10, 11); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
void setup() | void setup() | ||
{ | { | ||
| − | + | Serial.begin(38400); //Start serial communication at 9600 for debug statements | |
| + | Serial.println("YFRobot TM1650 Example Code"); | ||
| + | YF_4BitDis.init(); | ||
} | } | ||
void loop() | void loop() | ||
{ | { | ||
| + | YF_4BitDis.setBrightness(1); | ||
| + | YF_4BitDis.displayString(String("____")); | ||
| + | delay(1000); | ||
| + | char line[] = "1234"; | ||
| − | + | YF_4BitDis.displayString(line); | |
| − | + | YF_4BitDis.setBrightness(7); | |
| − | + | ||
| − | for (i = | + | for (int i = 1; i <= 8; i++) { |
| − | { | + | YF_4BitDis.setBrightness(i); |
| − | + | delay(200); | |
| + | } | ||
| + | for (int i = 1; i <= 8; i++) { | ||
| + | YF_4BitDis.setBrightness(8 - i); | ||
| + | delay(200); | ||
} | } | ||
| − | |||
| − | + | YF_4BitDis.displayString(-1.235); | |
| − | + | delay(1000); | |
| − | + | ||
| − | + | YF_4BitDis.displayString(12.10); | |
| − | + | delay(1000); | |
| − | + | ||
| − | + | YF_4BitDis.displayString(String("abcd")); | |
| + | delay(2000); | ||
| + | |||
| + | YF_4BitDis.displayString(2020); | ||
| + | delay(2000); | ||
| + | |||
| + | if (YF_4BitDis.displayRunning(String("1234567890abcdefghijklmnop"))) { | ||
delay(500); | delay(500); | ||
| + | while (YF_4BitDis.displayRunningShift()) { | ||
| + | delay(500); | ||
| + | } | ||
} | } | ||
| + | delay(2000); | ||
| − | + | for (int i = 0; i < 20; i++) { | |
| − | for ( | + | YF_4BitDis.displayOff(); |
| − | + | delay(200); | |
| − | + | YF_4BitDis.displayOn(); | |
| − | + | delay(200); | |
| − | + | ||
| − | + | ||
| − | delay( | + | |
} | } | ||
| − | + | ||
| − | for (i = 0; i < | + | for (int i = 0; i < 20; i++) { |
| − | + | YF_4BitDis.setBrightness(1); | |
| − | + | delay(200); | |
| + | YF_4BitDis.setBrightness(8); | ||
| + | delay(200); | ||
} | } | ||
| − | |||
| − | + | for (int i = 0; i < 20; i++) { | |
| − | + | for (int j = 0; j < 4; j++) { | |
| − | + | YF_4BitDis.setDot(j, true); | |
| − | + | delay(200); | |
| − | + | } | |
| − | + | for (int j = 0; j < 4; j++) { | |
| − | + | YF_4BitDis.setDot(j, false); | |
| + | delay(200); | ||
| + | } | ||
| + | } | ||
} | } | ||
</pre> | </pre> | ||
| − | 程序下载地址:[http://yfrobot.gitee.io/ino/ | + | 程序下载地址:[http://yfrobot.gitee.io/ino/TM1650.ino TM1650] |
程序运行结果:根据显示效果看程序,更方便理解 | 程序运行结果:根据显示效果看程序,更方便理解 | ||
2020年4月8日 (三) 14:00的版本
产品简介
4位数码管模块是采用TM1650专用数码管驱动芯片驱动4位0.56英寸数码管。模块提供小数点、时钟两种模式可选择,采用PH2.0-4P接口/XH2.54-4P排针接口,配合专用传感器线使用方便接线;且有M3安装柱可选配,方便固定。
TM1650 是专用的数码管驱动芯片,多可以驱动4个8段数码管,2线控制接口,节省单片机端口资源。通过芯片内部的寄存器可以设置显示的位数和显示的亮度,8级亮度可调。
将4位数码管模块加入项目中,可用来显示数值、时钟等信息。
规格参数
- 数码管:0.56 英寸,4 位
- 驱动IC:TM1650
- 工作电压 3V~5V
- 工作温度:-40℃~80℃
- 亮度等级:8 级亮度可设置
- 模块尺寸:50.5mm * 19.5mm
- 安装孔:3mm
- 安装孔中心距:42mm * 12mm
- 模块重量:3.8g
引脚说明
- 1. GND 黑线 -- Gnd(地)
- 2. VCC 红线 -- Vcc(电源+5V)
- 3. CLK 蓝线 -- 信号
- 3. DIO 白线 -- 信号
应用示例
电路连接
| 4位数码管显示模块 | Arduino UNO |
| VCC | +5V |
| GND | GND |
| CLK | D10 |
| DIO | D11 |
电路连接示意图
提示:以下程序需使用到 tm1650库文件,文件下载地址见页末 - 参考资料。下载后将其解压至arduinoIDE安装目录/libraries文件夹中,例如: "D:\Program Files\Arduino\arduino-1.6.4-windows\arduino-1.6.4\libraries"。
示例代码
示例一:4位数码管显示测试
/*
8-segment display driver of YFRobot 4-bit digital tube module based on TM1650 chip
Created by yfrobot,Released into the public domain.
*/
#include <YFTM1650.h>
YFTM1650 YF_4BitDis(10, 11);
void setup()
{
Serial.begin(38400); //Start serial communication at 9600 for debug statements
Serial.println("YFRobot TM1650 Example Code");
YF_4BitDis.init();
}
void loop()
{
YF_4BitDis.setBrightness(1);
YF_4BitDis.displayString(String("____"));
delay(1000);
char line[] = "1234";
YF_4BitDis.displayString(line);
YF_4BitDis.setBrightness(7);
for (int i = 1; i <= 8; i++) {
YF_4BitDis.setBrightness(i);
delay(200);
}
for (int i = 1; i <= 8; i++) {
YF_4BitDis.setBrightness(8 - i);
delay(200);
}
YF_4BitDis.displayString(-1.235);
delay(1000);
YF_4BitDis.displayString(12.10);
delay(1000);
YF_4BitDis.displayString(String("abcd"));
delay(2000);
YF_4BitDis.displayString(2020);
delay(2000);
if (YF_4BitDis.displayRunning(String("1234567890abcdefghijklmnop"))) {
delay(500);
while (YF_4BitDis.displayRunningShift()) {
delay(500);
}
}
delay(2000);
for (int i = 0; i < 20; i++) {
YF_4BitDis.displayOff();
delay(200);
YF_4BitDis.displayOn();
delay(200);
}
for (int i = 0; i < 20; i++) {
YF_4BitDis.setBrightness(1);
delay(200);
YF_4BitDis.setBrightness(8);
delay(200);
}
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 4; j++) {
YF_4BitDis.setDot(j, true);
delay(200);
}
for (int j = 0; j < 4; j++) {
YF_4BitDis.setDot(j, false);
delay(200);
}
}
}
程序下载地址:TM1650
程序运行结果:根据显示效果看程序,更方便理解
参考资料
更多建议和问题欢迎反馈至 YFRobot论坛
购买方式:YFRobot 电子工作室