금천고등학교 로고이미지

컴퓨터프로그래밍

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
[아두이노] 7세그먼트
작성자 김용남 등록일 21.06.17 조회수 30

// C++ code

//  https://www.tinkercad.com/things/6lTQttGwg4d

void setup()

{

  pinMode(4, OUTPUT); // A

  pinMode(5, OUTPUT); // B

  pinMode(12, OUTPUT); // C

  pinMode(11, OUTPUT); // D

  pinMode(10, OUTPUT); // E

  pinMode(3, OUTPUT);  // F

  pinMode(2, OUTPUT);  // G

  pinMode(13, OUTPUT); // DP

}

 

void loop()

{

  number0();     delay(1000); 

  number1();      delay(1000); 

  number2();     delay(1000); 

  number3();      delay(1000); 

  number4();     delay(1000); 

  number5();      delay(1000); 

  number6();     delay(1000); 

  number7();      delay(1000); 

  number8();      delay(1000); 

  number9();      delay(1000); 

}

 

 

void number0()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);     

  digitalWrite(12, LOW);    

  digitalWrite(11, LOW);     

  digitalWrite(10, LOW);      

  digitalWrite(3, LOW);    

  digitalWrite(2, HIGH);     

  digitalWrite(13, HIGH);     

}

 

void number1()

{

  digitalWrite(4, HIGH);     

  digitalWrite(5, LOW);      

  digitalWrite(12, LOW);     

  digitalWrite(11, HIGH);      

  digitalWrite(10, HIGH);     

  digitalWrite(3, HIGH);       

  digitalWrite(2, HIGH);     

  digitalWrite(13, HIGH);     

}

 

void number2()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);      

  digitalWrite(12, HIGH);     

  digitalWrite(11, LOW);       

  digitalWrite(10, LOW);    

  digitalWrite(3, HIGH);      

  digitalWrite(2, LOW);    

  digitalWrite(13, HIGH);      

}

 

void number3()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);      

  digitalWrite(12, LOW);     

  digitalWrite(11, LOW);       

  digitalWrite(10, HIGH);    

  digitalWrite(3, HIGH);      

  digitalWrite(2, LOW);    

  digitalWrite(13, HIGH);      

}

 

void number4()

{

  digitalWrite(4, HIGH);    

  digitalWrite(5, LOW);     

  digitalWrite(12, LOW);      

  digitalWrite(11, HIGH);      

  digitalWrite(10, HIGH);     

  digitalWrite(3, LOW);    

  digitalWrite(2, LOW);     

  digitalWrite(13, HIGH);      

}

 

void number5()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, HIGH);    

  digitalWrite(12, LOW);    

  digitalWrite(11, LOW);      

  digitalWrite(10, HIGH);     

  digitalWrite(3, LOW);       

  digitalWrite(2, LOW);     

  digitalWrite(13, HIGH);     

}

 

void number6()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, HIGH);    

  digitalWrite(12, LOW);    

  digitalWrite(11, LOW);      

  digitalWrite(10, LOW);     

  digitalWrite(3, LOW);       

  digitalWrite(2, LOW);     

  digitalWrite(13, HIGH);     

}

 

void number7()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);    

  digitalWrite(12, LOW);    

  digitalWrite(11, HIGH);      

  digitalWrite(10, HIGH);     

  digitalWrite(3, HIGH);       

  digitalWrite(2, HIGH);     

  digitalWrite(13, HIGH);     

}

 

void number8()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);    

  digitalWrite(12, LOW);    

  digitalWrite(11, LOW);      

  digitalWrite(10, LOW);     

  digitalWrite(3, LOW);       

  digitalWrite(2, LOW);     

  digitalWrite(13, HIGH);     

}

 

void number9()

{

  digitalWrite(4, LOW);     

  digitalWrite(5, LOW);    

  digitalWrite(12, LOW);    

  digitalWrite(11, LOW);      

  digitalWrite(10, HIGH);     

  digitalWrite(3, LOW);       

  digitalWrite(2, LOW);     

  digitalWrite(13, HIGH);     

}

이전글 [아두이노] 학습 사이트 안내
다음글 [프로세싱] 글자 움직이기