아두이노로 FND 6자리 출력하기
2019. 7. 8. 17:10ㆍ드론
데이터 핀은 13~6번까지 총 8개를, FND 선택 핀은 5~0번까지 총 6개를 연결한 상태다
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t aFndData[16] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x27, | |
0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71}; | |
uint8_t aFndSelData[6] = {0x3E, 0x3D, 0x3B, 0x37, 0x2F, 0x1F}; | |
int aPinFndData[8] = {13, 12, 11, 10, 9, 8, 7, 6}; | |
int aPinFndSel[6] = {5, 4, 3, 2, 1, 0}; | |
void setup() { | |
// put your setup code here, to run once: | |
for(int i=0; i<8; i++) { | |
pinMode(aPinFndData[i], OUTPUT); | |
} | |
for(int i=0; i<6; i++) { | |
pinMode(aPinFndSel[i], OUTPUT); | |
} | |
} | |
void loop() { | |
for(int k=0; k<6; k++) { | |
fndSelOut(aFndSelData[k]); | |
for(int i=0; i<16; i++) { | |
fndDataOut(aFndData[i]); | |
delay(200); | |
} | |
} | |
} | |
void fndDataOut(uint8_t data) { | |
for(int i=0; i<8; i++) { | |
digitalWrite(aPinFndData[i], (data >> i) & 0x01); | |
} | |
} | |
void fndSelOut(uint8_t data) { | |
for(int i=0; i<6; i++) { | |
digitalWrite(aPinFndSel[i], (data >> i) & 0x01); | |
} | |
} |
입력값을 정해서 내보내는 경우
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t aFndData[16] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x27, | |
0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71}; | |
uint8_t aFndSelData[6] = {0x3E, 0x3D, 0x3B, 0x37, 0x2F, 0x1F}; | |
int aPinFndData[8] = {13, 12, 11, 10, 9, 8, 7, 6}; | |
int aPinFndSel[6] = {5, 4, 3, 2, 1, 0}; | |
void setup() { | |
// put your setup code here, to run once: | |
for(int i=0; i<8; i++) { | |
pinMode(aPinFndData[i], OUTPUT); | |
} | |
for(int i=0; i<6; i++) { | |
pinMode(aPinFndSel[i], OUTPUT); | |
} | |
} | |
void loop() { | |
int aFndNum[6] = {0, 1, 3, 5, 7, 9}; | |
for(int k=0; k<6; k++) { | |
fndSelOut(aFndSelData[k]); | |
fndDataOut(aFndData[aFndNum[k]]); | |
delay(2); | |
} | |
} | |
void fndDataOut(uint8_t data) { | |
for(int i=0; i<8; i++) { | |
digitalWrite(aPinFndData[i], (data >> i) & 0x01); | |
} | |
} | |
void fndSelOut(uint8_t data) { | |
for(int i=0; i<6; i++) { | |
digitalWrite(aPinFndSel[i], (data >> i) & 0x01); | |
} | |
} |
'드론' 카테고리의 다른 글
아두이노 인터럽트로 제어하는 HIT 센서 (0) | 2019.07.09 |
---|---|
아두이노 Reed 자기 센서 제어 (0) | 2019.07.09 |
아두이노 스위치 입력 한번만 받기 (0) | 2019.07.08 |
아두이노 serialEvent 인터럽트 (0) | 2019.07.08 |
아두이노 LED 왕복해서 출력 (0) | 2019.07.08 |