• 검색 결과가 없습니다.

//LED 가 연결된 핀번호 12 const char LED_count=sizeof(LED)/sizeof(LED[0

N/A
N/A
Protected

Academic year: 2022

Share "//LED 가 연결된 핀번호 12 const char LED_count=sizeof(LED)/sizeof(LED[0"

Copied!
1
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

1 //버튼을 누를 때마다 LED 를 모두 켜거나 끄는 프로그램 ver.3 2 //LED 초기상태 0 0 0 0

3 //버튼 한번 누름1 1 1 1 4 //다시 한번 누름0 0 0 0 5 //다시 한번 누름1 1 1 1 6 //같은 형태로 반복함 7

8 #include <wiringPi.h>

9

10 #define BUTTON 21 //버튼이 연결된 핀번호 11 const char LED[4]={27, 28, 29, 25}; //LED 가 연결된 핀번호 12 const char LED_count=sizeof(LED)/sizeof(LED[0]);

13 char input_last=HIGH, input_now=HIGH;

14

15 void init();

16 char read_button();

17

18 int main(void){

19 char led=LOW;

20

21 init();

22

23 while(1){

24 if(read_button())

25 led=!led;

26

27 for(int i=0;i<LED_count;i++) 28 digitalWrite(LED[i], led);

29

30 delay(20);

31 }

32 return 0;

33 } 34

35 void init() 36 {

37 wiringPiSetup();

38 pinMode(BUTTON, INPUT);

39 for(int i=0;i<LED_count;i++){

40 pinMode(LED[i],OUTPUT);

41 digitalWrite(LED[i], LOW);

42 } 43 } 44

45 char read_button() 46 {

47 char result=FALSE;

48 input_now=digitalRead(BUTTON);

49 if(input_last==HIGH && input_now==LOW) 50 result=TRUE;

51 input_last=input_now;

52

53 return result;

54 }

참조

관련 문서

LED for operation switch display 6 LEDs, green (lighting control from the display section) LED for grip switch display 1 LED, green (lighting control from display unit

We therefore link these wonderful creatures to our LIN RGB products which enable changing ambient light according to the car

[r]

따라서 오늘날 녹색 에너지 전문가가 하는 일을 이해하며 , ‘풍력을 이용한 등대’를 만 들어 봄으로써 녹색 에너지 전문가에게 필요한 역량을 무엇인지 탐색해 보고 자

LED(Light Emitting

STEAM 프로그램의 효율적인 적용을 위하여 프로그램을 운영하시는 선생님들께서 는 학생들 스스로 문제를 파악하고 해결할 수 있도록 도와주는 역할을 해주시기

take measures to prevent ESD problem (for example, grounding equipment and the human body, using grounded soldering iron and

auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void.. default