“4位数码管模块”的版本间的差异

来自YFRobotwiki
跳转至: 导航搜索
 
(未显示2个用户的25个中间版本)
第6行: 第6行:
 
=== 产品简介 ===
 
=== 产品简介 ===
 
<br>
 
<br>
<strike>10K电 用WH148 10K电位器,3引脚直 杜邦线 方便 !</strike>
+
4 数码管模块是 用TM1650专用数码管驱动芯片驱动4位0.56英寸数码管。模块提供小数点、时钟两种模式可选择,采用PH2.0-4P 口/XH2.54-4P排针 配合专用传感器线使用方便 线;且有M3安装柱可选配, 方便 固定。
  
4位 数码管 模块
+
TM1650 是专用的 数码管 驱动芯片,多可以驱动4个8段数码管,2线控制接口,节省单片机端口资源。通过芯片内部的寄存器可以设置显示的位数和显示的亮度,8级亮度可调。
0.56英寸
+
 
 
+
  将4位 码管模块加入项目中,可用来显示数值、 时钟 等信息。
时钟 ()
+
  
  
第17行: 第16行:
 
=== 规格参数 ===
 
=== 规格参数 ===
 
<br>
 
<br>
1) 数码管:0.36 英寸,4 位
+
* 数码管:0.56 英寸,4 位
 
+
* 驱动IC:TM1650
2) 驱动IC:TM1650
+
* 工作电压 3V~5V
 
+
* 工作温度:-40℃~80℃
3) 工作电压 3V~5V
+
* 亮度等级:8 级亮度可设置
 
+
* 模块尺寸:50.5mm * 19.5mm  
4)输入电压 3V~5.5V
+
 
+
5) 工作温度:-40℃~80℃
+
 
+
6) 亮度等级:8 级亮度可设置
+
 
+
7) 模块尺寸:50.5mm * 19.5mm  
+
8)安装孔中心距:42mm * 12mm
+
+
9)生产工艺:环保无铅
+
*模块尺寸:28*21*24MM(长*宽*高)
+
 
*安装孔:3mm
 
*安装孔:3mm
*安装孔 :15mm
+
*安装孔 中心 :42mm * 12mm
 
*模块重量:3.8g
 
*模块重量:3.8g
  
第42行: 第30行:
 
=== 引脚说明 ===
 
=== 引脚说明 ===
 
<br>
 
<br>
*1. G 黑线  --  Gnd(地)
+
*1. GND 黑线  --  Gnd(地)
*2. V 红线  --  Vcc(电源+5V)
+
*2. VCC 红线  --  Vcc(电源+5V)
*3. S 白线  --  信号
+
*3. CLK 蓝线  --  信号
 +
*3. DIO 白线  --  信号
  
  
 
=== 应用示例 ===
 
=== 应用示例 ===
 +
<br>
 +
 +
'''电路连接'''
 +
 +
<br>
 +
{|border="1" cellspacing="0" align="center" cellpadding="5" width="600px"
 +
|-
 +
|align="center"|4位数码管显示模块
 +
|align="center"|Arduino UNO
 +
|-
 +
|align="center"|VCC
 +
|align="center"|+5V
 +
|-
 +
|align="center"|GND
 +
|align="center"|GND
 +
|-
 +
|align="center"|CLK
 +
|align="center"|D10
 +
|-
 +
|align="center"|DIO
 +
|align="center"|D11
 +
|}
 +
 
<br>
 
<br>
  
 
'''电路连接示意图'''
 
'''电路连接示意图'''
 +
 
<br>
 
<br>
:'''电位器模块'''的 G、V、S分别连接 '''Arduino UNO'''的GND、VCC(+5V)、A0引脚。
+
<img src="http://yfrobot.gitee.io/wiki/img/4位数码管显示.png"  alt="4位数码管显示" />
<img src="http://wiki.yfrobot.com/image/sensor_circuit/potentiometer1.png-yf"  alt="potentiometer1" />
+
 
+
  
 +
<font color="darkorenge">''' 提示'''</font>:以下程序需使用到 [http://yfrobot.gitee.io/wiki/lib/YFTM1650.rar TM1650库文件]。下载后将其解压至arduinoIDE安装目录/libraries文件夹中,例如: "D:\Program Files\Arduino\arduino-1.6.4-windows\arduino-1.6.4\libraries"。
  
 
'''示例代码'''
 
'''示例代码'''
 
<br><br>
 
<br><br>
<font color="darkcyan">'''示例一'''</font> :电 器值串口打印
+
<font color="darkcyan">'''示例一'''</font> :4 数码管显示测试
 
<br>
 
<br>
<pre >
+
 
 +
 
 +
<source lang="c">
 
/*
 
/*
Potentiometer Test
+
  8-segment display driver of YFRobot 4-bit digital tube module based on TM1650 chip
 +
  Created by yfrobot,Released into the public domain.
 
*/
 
*/
int pPin = A0;
+
 
int pVal = 0;
+
#include <YFTM1650.h>
int pVal_old = 0;
+
 
 +
YFTM1650 YF_4BitDis(10, 11);
 +
 
 
void setup()
 
void setup()
 
{
 
{
   pinMode(pPin,INPUT);    
+
   Serial.begin(38400); //Start serial communication at 9600 for debug statements
   Serial.begin(9600);
+
   Serial.println("YFRobot TM1650 Example Code");
 +
  YF_4BitDis.init();
 
}
 
}
 +
 
void loop()
 
void loop()
 
{
 
{
   //读取A0模拟口的数值(0-5V 对应 0-1204取值)
+
   YF_4BitDis.setBrightness(1);
  pVal = analogRead(pPin);  
+
   YF_4BitDis.displayString(String("____"));
   if(abs(pVal - pVal_old) >= 2 ){
+
  delay(1000);
    Serial.println(pVal);
+
   char line[] = "1234";
    pVal_old = pVal;
+
   }
+
}
+
</pre>
+
程序下载地址:[https://eyun.baidu.com/s/3miecpcc PotentiometerTest]
+
  
程序运行结果:电位器值串口打印,结果如下图:
+
  YF_4BitDis.displayString(line);
 +
  YF_4BitDis.setBrightness(7);
  
[[File:电位器串口输出.png|450px|center]]
+
  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);
  
<br><br>
+
  YF_4BitDis.displayString(12.10);
<font color="darkcyan">'''示例二'''</font>:电位器控制[http://www.yfrobot.com/wiki/index.php?title=%E5%BD%A9%E8%89%B2LED%E6%A8%A1%E5%9D%97 彩色LED模块]变色
+
  delay(1000);
<br>
+
'''电路连接示意图'''
+
  
<img src="http://wiki.yfrobot.com/image/sensor_circuit/potentiometer2.png-yf"  alt="potentiometer2" />
+
  YF_4BitDis.displayString(String("abcd"));
<br>
+
  delay(2000);
  
<pre>
+
  YF_4BitDis.displayString(2020);
 +
  delay(2000);
  
/*
+
  if (YF_4BitDis.displayRunning(String("1234567890abcdefghijklmnop"))) {
   Potentiometer control RGB LED change color
+
    delay(500);
*/
+
    while (YF_4BitDis.displayRunningShift()) {
 +
      delay(500);
 +
    }
 +
   }
 +
  delay(2000);
  
#include <Adafruit_NeoPixel.h>
+
  for (int i = 0; i < 20; i++) {
 +
    YF_4BitDis.displayOff();
 +
    delay(200);
 +
    YF_4BitDis.displayOn();
 +
    delay(200);
 +
  }
  
#define RGBLEDPin  5
+
   for (int i = 0; i < 20; i++) {
#define NUMPIXELS  4
+
     YF_4BitDis.setBrightness(1);
#define pPin  A0
+
     delay(200);
 
+
     YF_4BitDis.setBrightness(8);
// Parameter 1 = number of pixels in strip
+
     delay(200);
// Parameter 2 = pin number (most are valid)
+
// Parameter 3 = pixel type flags, add together as needed:
+
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
+
//  NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
+
//  NEO_GRB    Pixels are wired for GRB bitstream (most NeoPixel products)
+
//  NEO_RGB    Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
+
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, RGBLEDPin, NEO_GRB + NEO_KHZ800);
+
 
+
int pVal = 0;
+
int RVal = 0;
+
int GVal = 0;
+
int BVal = 0;
+
 
+
void setup()
+
{
+
  pinMode(RGBLEDPin, OUTPUT);
+
  pixels.begin(); // This initializes the NeoPixel library.
+
  pixels.show();
+
}
+
 
+
void loop()
+
{
+
  pVal = analogRead(pPin);    //读取A0模拟口的数值(0-5V 对应 0-1203取值)
+
  if (pVal >= 0 && pVal <= 170) {
+
    RVal = 255;
+
    GVal = 0;
+
    BVal = map(pVal, 0, 170, 0, 255);
+
  } else if (pVal > 170 && pVal <= 340) {
+
     RVal = map(pVal, 170, 340, 255, 0);
+
     GVal = 0;
+
    BVal = 255;
+
  } else if (pVal > 340 && pVal <= 510) {
+
    RVal = 0;
+
     GVal = map(pVal, 340, 510, 0, 255);
+
     BVal = 255;
+
  } else if (pVal > 510 && pVal <= 680) {
+
    RVal = 0;
+
    GVal = 255;
+
    BVal = map(pVal, 510, 680, 255, 0);
+
  } else if (pVal > 680 && pVal <= 850) {
+
    RVal = map(pVal, 680, 850, 0, 255);
+
    GVal = 255;
+
    BVal = 0;
+
  } else {
+
    RVal = 255;
+
    GVal = map(pVal, 850, 1023, 255, 0);
+
    BVal = 0;
+
 
   }
 
   }
  lightLED(RVal, GVal, BVal);
 
}
 
  
void lightLED(int r, int g , int b) {
+
   for (int i = 0; i < 20; i++) {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
+
     for (int j = 0; j < 4; j++) {
   for (int i = 0; i < NUMPIXELS; i++) {
+
      YF_4BitDis.setDot(j, true);
     // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
+
      delay(200);
    pixels.setPixelColor(i, r, g, b); // Moderately bright green color.
+
     }
     pixels.show(); // This sends the updated pixel color to the hardware.
+
    for (int j = 0; j < 4; j++) {
 +
      YF_4BitDis.setDot(j, false);
 +
      delay(200);
 +
    }
 
   }
 
   }
 
}
 
}
 +
</source>
 +
程序下载地址:[http://yfrobot.gitee.io/wiki/ino/TM1650.ino TM1650]
  
</pre>
+
程序运行结果:根据显示效果看程序,更方便理解
  
程序下载地址:[https://eyun.baidu.com/s/3dFaSHgP ChangeColor]
 
  
程序运行结果:转动电位器,彩色led变色。
 
  
 
 
<!--
 
 
===参考资料===
 
===参考资料===
 
<br>
 
<br>
-->
+
[http://yfrobot.gitee.io/wiki/lib/YFTM1650_V1.2.rar TM1650库文件]
 +
 
  
  

2022年9月3日 (六) 08:51的最后版本

生成缩略图出错:文件可能丢失:
4位数码管


产品简介


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


电路连接示意图


4位数码管显示

提示:以下程序需使用到 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

程序运行结果:根据显示效果看程序,更方便理解


参考资料


TM1650库文件





返回首页

更多建议和问题欢迎反馈至 YFRobot论坛

购买方式:YFRobot 电子工作室