2017년 8월 11일 금요일
2-Digit FND(F4201AH) 아날로그입력값 표시
int a[2] = {10,11};
int fnd_a = 2;
int buffer[2] = {0};
int analogValue;
unsigned char table[10][7] = {
{1,1,1,1,1,1,0}, //0
{0,1,1,0,0,0,0}, //1
{1,1,0,1,1,0,1}, //2
{1,1,1,1,0,0,1}, //3
{0,1,1,0,0,1,1}, //4
{1,0,1,1,0,1,1}, //5
{1,0,1,1,1,1,1}, //6
{1,1,1,0,0,1,0}, //7
{1,1,1,1,1,1,1}, //8
{1,1,1,0,0,1,1} //9
};
void setup()
{
Serial.begin(9600);
int i,j;
for(i=fnd_a; i<fnd_a+7; i++) //FND a핀부터 g핀까지 포트설정
pinMode(i, OUTPUT);
for(j=0; j<2; j++) //FND Control PIN
pinMode(a[j], OUTPUT);
}
void fnd(int STATUS)
{
int j;
switch(STATUS){
case 0: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[0][j]); break;
case 1: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[1][j]); break;
case 2: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[2][j]); break;
case 3: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[3][j]); break;
case 4: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[4][j]); break;
case 5: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[5][j]); break;
case 6: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[6][j]); break;
case 7: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[7][j]); break;
case 8: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[8][j]); break;
case 9: for(j=0; j<7; j++) digitalWrite(fnd_a+j, table[9][j]); break;
}
}
void loop()
{
int i,k = 0;
int STATUS;
analogValue = analogRead(A0);
Serial.println(analogValue);
buffer[1] = (analogValue%100)/10;
buffer[0] = analogValue%10;
for(i=0; i<2; i++){
STATUS = buffer[1-i];
fnd(STATUS);
digitalWrite(a[k],LOW);
delay(10);
digitalWrite(a[k],HIGH);
k++;
k = k % 2;
}
}
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기