#include "TM1637.h"
#define CLK 2//pins definitions for TM1637 and can be changed to other ports
#define DIO 3
TM1637 tm1637(CLK,DIO);
void setup()
{
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
pinMode(A0,INPUT);
}
void loop()
{
int cnt1=0,cnt10=0,cnt100=0, cnt1000=0, adRead=0, cnt=0;
delay(150);
while(1)
{
adRead=analogRead(A0);
tm1637.display(0,cnt1000); // 1000
tm1637.display(1,cnt100); // 100
tm1637.display(2,cnt10); // 10
tm1637.display(3,cnt1); // 1
delay(20);
cnt1000=adRead/1000; //1=1234
cnt=adRead%1000; //234=1234
cnt100=cnt/100; //2=234
cnt=cnt%100; //34=234
cnt10=cnt/10; //3=34
cnt1=cnt%10; //4=34
}
}
'Study > Arduino' 카테고리의 다른 글
Intel Galileo (0) | 2014.09.15 |
---|---|
FND Number Count (0) | 2014.09.15 |
4-Digit Display header file (0) | 2014.09.15 |
Grove-LCD RGB Backlight header file (0) | 2014.09.15 |
SW체터링 소프트웨어적 해결 (0) | 2014.09.05 |