●7 segment LED 디지털 튜브
- 7개의 작대기로 문자를 표시하는 LED디저털 튜브이다.
●0~9까지 표시하는 예제
#define ledA 7 #define ledB 8 #define ledC 2 #define ledD 3 #define ledE 4 #define ledF 6 #define ledG 5 void setup() { pinMode(ledA, OUTPUT); pinMode(ledB, OUTPUT); pinMode(ledC, OUTPUT); pinMode(ledD, OUTPUT); pinMode(ledE, OUTPUT); pinMode(ledF, OUTPUT); pinMode(ledG, OUTPUT); } void loop() { // 1 digitalWrite(ledD, LOW); digitalWrite(ledE, LOW); digitalWrite(ledF, LOW); digitalWrite(ledG, LOW); digitalWrite(ledA, LOW); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 2 digitalWrite(ledD, HIGH); digitalWrite(ledE, HIGH); digitalWrite(ledF, LOW); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, LOW); delay(1000); // 3 digitalWrite(ledD, HIGH); digitalWrite(ledE, LOW); digitalWrite(ledF, LOW); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 4 digitalWrite(ledD, LOW); digitalWrite(ledE, LOW); digitalWrite(ledF, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledA, LOW); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 5 digitalWrite(ledD, HIGH); digitalWrite(ledE, LOW); digitalWrite(ledF, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, LOW); digitalWrite(ledC, HIGH); delay(1000); // 6 digitalWrite(ledD, HIGH); digitalWrite(ledE, HIGH); digitalWrite(ledF, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, LOW); digitalWrite(ledC, HIGH); delay(1000); // 7 digitalWrite(ledD, LOW); digitalWrite(ledE, LOW); digitalWrite(ledF, LOW); digitalWrite(ledG, LOW); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 8 digitalWrite(ledD, HIGH); digitalWrite(ledE, HIGH); digitalWrite(ledF, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 9 digitalWrite(ledD, HIGH); digitalWrite(ledE, LOW); digitalWrite(ledF, HIGH); digitalWrite(ledG, HIGH); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000); // 0 digitalWrite(ledD, HIGH); digitalWrite(ledE, HIGH); digitalWrite(ledF, HIGH); digitalWrite(ledG, LOW); digitalWrite(ledA, HIGH); digitalWrite(ledB, HIGH); digitalWrite(ledC, HIGH); delay(1000);
}
|
'프로그래밍 > 아두이노' 카테고리의 다른 글
아두이노 블루투스로 안드로이드 연결하기 (0) | 2016.01.05 |
---|---|
아두이노 Serial 사용해서 PC와 연결하기 (0) | 2016.01.04 |
아두이노 RGB 제어하기 (0) | 2016.01.02 |
아두이노 적외선 리모콘 (0) | 2016.01.01 |
아두이노 빛의 세기에 따라 소리,LED밝기 조절 예제 (0) | 2016.01.01 |
댓글