Ch3_2. 키입력으로 LED 깜박이기
학습 내용
mbed의 입력핀을 이용하여 외부 스위치의 ON/OFF 신호를 읽어 출력핀에 연결된 LED를 점등시키고 소등시키는 제어를 학습하게됩니다.
배선도
        
  
회로도
      
  
      
배선 사진
  
 
Flow Chart
   
  
코딩
#include "mbed.h"
BusOut leds(p5, p6, p7, p8, p9, p10, p11, p12);
DigitalIn button1(p21);
DigitalIn button2(p22);
DigitalIn button3(p23);
DigitalIn button4(p24);
int main() {
    volatile unsigned long Loop;
    char state;
    state = 0xF0;           
     
     while (1)
     {
         button1.mode(PullUp);
         
         if(button1 == 0) 
         {
         state = ~state;
         
         for(Loop = 0; Loop < 200000; Loop++);
         }
         
      leds = state;
     }
}
라이브러리
학습 참고
Please log in to post comments.
