6digit FND
2020. 5. 25. 15:01
Programing/Arduino
6digit FND
const int sel[6] = {30,31,32,33,34,35};
const int data[8] = {22,23,24,25,26,27,28,29};
unsigned long value=0;
unsigned char numData[10][8] =
{//a,b,c,d,e,f,g,dp
{1,1,1,1,1,1,0,0}, //0
{0,1,1,0,0,0,0,0}, //1
{1,1,0,1,1,0,1,0}, //2
{1,1,1,1,0,0,1,0}, //3
{0,1,1,0,0,1,1,0}, //4
{1,0,1,1,0,1,1,0}, //5
{1,0,1,1,1,1,1,0}, //6
{1,1,1,0,0,1,0,0}, //7
{1,1,1,1,1,1,1,0}, //8
{1,1,1,0,0,1,1,0} //9
};
void setup() {
// put your setup code here, to run once:
for(int i = 0; i<14;i++)
pinMode(i+22,OUTPUT);
for(int i = 0;i<6;i++)
digitalWrite(sel[i],HIGH);
}
void loop() {
fndprint(500);
}
void fndprint(int num){
int i, temp =0;
fndOff();
digitalWrite(sel[0],LOW);
temp=num/100000;
for(i = 0;i<8;i++)
digitalWrite(data[i], numData[temp][i]);
delay(1);
fndOff();
digitalWrite(sel[1],LOW);
num=num%100000;
temp=num/10000;
for(i=0;i<8;i++)
digitalWrite(data[i],numData[temp][i]);
delay(1);
fndOff();
digitalWrite(sel[2],LOW);
num=num%10000;
temp=num/1000;
for(i=0;i<8;i++)
digitalWrite(data[i],numData[temp][i]);
delay(1);
fndOff();
digitalWrite(sel[3],LOW);
num=num%1000;
temp=num/100;
for(i=0;i<8;i++)
digitalWrite(data[i],numData[temp][i]);
delay(1);
fndOff();
digitalWrite(sel[4],LOW);
num=num%100;
temp=num/10;
for(i=0;i<8;i++)
digitalWrite(data[i],numData[temp][i]);
delay(1);
fndOff();
digitalWrite(sel[5],LOW);
temp=num%10;
for(i=0;i<8;i++)
digitalWrite(data[i],numData[temp][i]);
delay(1);
}
void fndOff(){
for(int i=0;i<6;i++)
digitalWrite(sel[i],HIGH);
}
'Programing > Arduino' 카테고리의 다른 글
6FND, 초음파, 서보모터, Buzzer,매트릭스 키패드 (0) | 2020.05.27 |
---|---|
LED,가변저항,버튼 제어 (0) | 2020.05.05 |
LED 6개 순차 깜빡 (0) | 2020.05.03 |