4位數碼管模塊
出自YFRobotwiki
創建縮圖錯誤: 檔案似乎遺失:
產品簡介
4位數碼管模塊是採用0.56英寸4位數碼管設計製作,有小數點、時鐘兩種模式可選擇,採用PH2.0-4P接口/XH2.54-4P排針接口,配合專用傳感器線使用方便接線;且有M3安裝柱可選配,方便固定。
將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位數碼管顯示測試
/*------------------------------------------------------------------------------------ TM1650 nixie tube This example code shows how to use the functions of the TM1650 Library. -------------------------------------------------------------------------------------*/ /*************************************************************************************/ #include<tm1650.h> #define ON DISPLAY_ON #define OFF DISPLAY_OFF #define SegmentMode _8_SEGMENT_MODE unsigned char LightLevel = LV2; unsigned char WorkMode = NORMAL_MODE; //define each segment const unsigned char Seg_test[8] = {0x20, 0x01, 0x02, 0x04, 0x08, 0x10, 0x40, 0x80}; //number 0-9 code const unsigned char Number_arr[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f}; unsigned char i, j = 0, k = 0, l = 0, m = 0; unsigned char temp[4] = {0x3f, 0x06, 0x5b, 0x4f}; boolean err = 0; int pin_SCK = 10; int pin_DIO = 11; TM1650 tm1650(pin_SCK, pin_DIO); void setup() { } void loop() { //config tm1650 err = tm1650.DisplayConfig_TM1650(LightLevel, SegmentMode, WorkMode, ON); //all nixie tube turn on for (i = 0; i < 4; i++) { err = tm1650.DisplayOneDigi_TM1650(i + 1, 0xFF); } delay(500); //loop each segment for (m = 0; m < 8; m++) { for (i = 0; i < 4; i++) { err = tm1650.DisplayOneDigi_TM1650(i + 1, Seg_test[m]); } delay(500); } //display form 0 to 9 for (m = 0; m <= 9; m++) { for (i = 0; i < 4; i++) { err = tm1650.DisplayOneDigi_TM1650(i + 1, Number_arr[m]); } delay(500); } //display the content of array temp[] for (i = 0; i < 4; i++) { err = tm1650.DisplayOneDigi_TM1650(i + 1, temp[i]); } delay(500); //all turn off err = tm1650.DisplayOFF_TM1650(LightLevel, SegmentMode, WorkMode); delay(1000); //turn on again err = tm1650.DisplayON_TM1650(LightLevel, SegmentMode, WorkMode); delay(1000); }
程序下載地址:TM1650_nixie_tube
程序運行結果:根據顯示效果看程序,更方便理解
示例二:電位器控制彩色LED模塊變色
電路連接示意圖
/* Potentiometer control RGB LED change color */ #include <Adafruit_NeoPixel.h> #define RGBLEDPin 5 #define NUMPIXELS 4 #define pPin A0 // Parameter 1 = number of pixels in strip // 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 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 i = 0; i < NUMPIXELS; i++) { // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 pixels.setPixelColor(i, r, g, b); // Moderately bright green color. pixels.show(); // This sends the updated pixel color to the hardware. } }
程序下載地址:ChangeColor
程序運行結果:轉動電位器,彩色led變色。
更多建議和問題歡迎反饋至 YFRobot論壇
購買方式:YFRobot 電子工作室