电路安装:
GND---GND
VCC---3V3
DIO---D3
CLK---D2
TM1637库安装:
下载:
https://pan.baidu.com/s/1TtbN_LEAzAUtrHLhBDxqxQ
密码:f6fv
解压到C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries
即可
代码:
#include <TM1637.h>
TM1637 tm1637(2, 3);
// 2 clk
// 3 dio
void setup() {
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
}
void xssz(int num) {
tm1637.display(0, num / 1000);
tm1637.display(1, num % 1000 / 100);
tm1637.display(2, num % 100 / 10);
tm1637.display(3, num % 10);
}
int i = 0;
void loop() {
i++;
xssz(i);
delay(100);
}
效果:
Arduino 数字显示