본문 바로가기
프로그래밍/아두이노

아두이노 7 segment LED 디지털 튜브

by -현's- 2016. 1. 2.
반응형


●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);

  

}

 









반응형

댓글