본문 바로가기

유수봉 교수의 AI

유수봉 교수의 AI-2주차

#1번 실습

 

 

 

#1번 실습 작동영상

 

 

사용한 코드

 

 

// C++ code
//
void setup()
{
  for(int N=0; N<10; N++) {
   pinMode(N, OUTPUT);
  }
}
void cls() {
  for(int N=0; N<10; N++) {
    digitalWrite(N, LOW);
  }
  delay(100);
}
void loop()
{
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, HIGH);  digitalWrite(6, HIGH);  digitalWrite(7, HIGH);  digitalWrite(8, LOW);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
  
  digitalWrite(2, LOW);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, LOW);  digitalWrite(6, LOW);  digitalWrite(7, LOW);  digitalWrite(8, LOW);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
  
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, LOW);  digitalWrite(5, HIGH);  digitalWrite(6, HIGH);  digitalWrite(7, LOW);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, HIGH);  digitalWrite(6, LOW);  digitalWrite(7, LOW);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, LOW);  digitalWrite(4, LOW);  digitalWrite(5, LOW);  digitalWrite(6, HIGH);  digitalWrite(7, HIGH);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, LOW);  digitalWrite(4, HIGH);  digitalWrite(5, HIGH);  digitalWrite(6, LOW);  digitalWrite(7, HIGH);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, LOW);  digitalWrite(3, LOW);  digitalWrite(4, HIGH);  digitalWrite(5, HIGH);  digitalWrite(6, HIGH);  digitalWrite(7, HIGH);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, LOW);  digitalWrite(6, LOW);  digitalWrite(7, LOW);  digitalWrite(8, LOW);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, HIGH);  digitalWrite(6, HIGH);  digitalWrite(7, HIGH);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
    
  digitalWrite(2, HIGH);  digitalWrite(3, HIGH);  digitalWrite(4, HIGH);  digitalWrite(5, LOW);  digitalWrite(6, LOW);  digitalWrite(7, HIGH);  digitalWrite(8, HIGH);  digitalWrite(9, LOW);
  delay(500); 
  //cls();
}

 

 

#2번 실습

 

 

 

#2번 실습 작동영상

 

 

사용한 코드

 

int N=0;

void setup(){
  for(int X=2; X<14; X++) {
     pinMode(X, OUTPUT);
  }
}

void CLS(){
  for(int X=2; X<10; X++) { 
     digitalWrite(X, HIGH); 
  }
}

void disp(int N) {
switch (N){
case 1 :digitalWrite(3, LOW); digitalWrite(4, LOW); break;
case 2 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(8, LOW); break;
case 3 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(8, LOW); break;
case 4 :digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); break;
case 5 :digitalWrite(2, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); break;
case 6 :digitalWrite(2, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); break;
case 7 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); break;
case 8 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); break;
case 9 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); break;
case 0 :digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); digitalWrite(6, LOW); digitalWrite(7, LOW); break;

}

void F1(){digitalWrite(12, LOW);digitalWrite(13, HIGH);}
void F2(){digitalWrite(12, HIGH);digitalWrite(13, LOW);}

void loop(){ 
N++;
for (int R = 0; R < 100; R++) {
     F1(); disp(int(N / 10) % 10);  delay(2); CLS(); 
     F2(); disp(N % 10);  delay(3); CLS();
   }
}

 

 

#3번 실습

 

 

 

#3번 실습 작동영상

 

 

사용된 코드

 

void setup(){
    for (int X = 0;  X < 14; X++) {
      pinMode(X, OUTPUT); 
      digitalWrite(X, LOW);
    }
}

int N=0;
int HH=0, MM=0;
void loop() {
  MM++;
  if(MM==60){HH++; MM=0;}
  if(HH==24){HH=0; MM=0;}
  
  for(int A=0; A<20; A++){
    CLS();digitalWrite(13, LOW); disp((HH/10)%10);    delay(3); 
    CLS();digitalWrite(12, LOW); disp((HH/1)%10);    delay(3); 
    if(MM%3) digitalWrite(9, HIGH);delay(3); 
    CLS();digitalWrite(11, LOW); disp((MM/10)%10);    delay(3); 
    CLS();digitalWrite(10, LOW); disp((MM/1)%10);    delay(3);
    
  }
}

void CLS(){ for(int X=10; X<14; X++) {digitalWrite(X, HIGH);}
     for(int X=2; X<10; X++) {digitalWrite(X, LOW);} 
}

void disp(int N) {
switch (N){
case 1 :digitalWrite(3, HIGH); digitalWrite(4, HIGH); break;
case 2 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(8, HIGH); break;
case 3 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(8, HIGH); break;
case 4 :digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); break;
case 5 :digitalWrite(2, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); break;
case 6 :digitalWrite(2, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); break;
case 7 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); break;
case 8 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); break;
case 9 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(7, HIGH); digitalWrite(8, HIGH); break;
case 0 :digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, HIGH); digitalWrite(6, HIGH); digitalWrite(7, HIGH); break;

}

 

 

 

 

 

https://blog.naver.com/newbongman/223380666654

'유수봉 교수의 AI' 카테고리의 다른 글

유수봉 교수의 AI-3주차  (0) 2024.03.22
유수봉 교수의 AI-2주차(졸작)  (0) 2024.03.20
유수봉 교수의 AI-1주차  (0) 2024.03.08
유수봉 교수의 AI-16주차  (1) 2023.12.08
유수봉 교수의 AI-15주차  (1) 2023.12.08