RB-05L021 4位7段數(shù)碼管模塊
來自ALSROBOT WiKi
目錄 |
產(chǎn)品概述
此產(chǎn)品由一個(gè)12管腳的4位7段共陽極數(shù)碼管和一個(gè)控制芯片TM1637構(gòu)成。該模塊采用沉金工藝,外觀更加美觀,同時(shí)采用防插反接口,操作更加安全,插口一邊有大寫字母I表示該模塊采用IIC協(xié)議通信,另一邊是數(shù)碼管的圖標(biāo)標(biāo)志。此產(chǎn)品可以應(yīng)用在時(shí)間顯示,跑表顯示以及其他需要顯示數(shù)字的設(shè)備上。
規(guī)格參數(shù)
- 工作電壓 : +5v
- 尺寸大?。?5mm x 25mm
- 重量大小:8g
- 通信協(xié)議:IIC
接口定義
- SCL:IIC時(shí)鐘信號引腳
- SDA:IIC數(shù)據(jù)信號引腳
- -:電源地
- +:電源正極
使用方法
連接示意圖
SCK引腳接到控制器的A5口, SDA引腳接到控制器的A4口。+和-分別接到電源的+5V和GND。
例子程序
#include <TimerOne.h> #include "TM1637.h" #define ON 1 #define OFF 0 int8_t TimeDisp[] = {0x00,0x00,0x00,0x00}; unsigned char ClockPoint = 1; unsigned char Update; unsigned char halfsecond = 0; unsigned char second; unsigned char minute = 0; unsigned char hour = 12; #define CLK A5//pins definitions for TM1637 and can be changed to other ports #define DIO A4 TM1637 tm1637(CLK,DIO); void setup() { tm1637.set(); tm1637.init(); Timer1.initialize(500000);//timing for 500ms Timer1.attachInterrupt(TimingISR);//declare the interrupt serve routine:TimingISR } void loop() { if(Update == ON) { TimeUpdate(); tm1637.display(TimeDisp); } } void TimingISR() { halfsecond ++; Update = ON; if(halfsecond == 2){ second ++; if(second == 60) { minute ++; if(minute == 60) { hour ++; if(hour == 24)hour = 0; minute = 0; } second = 0; } halfsecond = 0; } // Serial.println(second); ClockPoint = (~ClockPoint) & 0x01; } void TimeUpdate(void) { if(ClockPoint)tm1637.point(POINT_ON); else tm1637.point(POINT_OFF); TimeDisp[0] = hour / 10; TimeDisp[1] = hour % 10; TimeDisp[2] = minute / 10; TimeDisp[3] = minute % 10; Update = OFF; }
程序效果
注意程序中包含的頭文件需要下載,程序下載進(jìn)去之后就可以正常顯示時(shí)鐘了。
產(chǎn)品相關(guān)推薦
產(chǎn)品購買地址
周邊產(chǎn)品推薦
Arduino 8位靜態(tài)數(shù)碼管 掃描顯示器 SPI LED 數(shù)碼管
Arduino 8*8點(diǎn)陣模塊 單色 8X8 LED Matrix Module
Carduino UNO R3 控制器