loop()

Parent Previous Next

loop() 함수는 setup()함수의 실행이 끝난후 호출되며 함수의 실행이 끝나도 종료되지 않고 처음부터 다시 반복하여 실행됩니다.

실제 보드의 작동 및 제어에 사용됩니다.


예제 코드


const int buttonPin = 3;


// 시리얼 포트와 핀 모드를 초기화합니다.

void setup()

{

 Serial.begin(9600);

 pinMode(buttonPin, INPUT);

}


// buttonPin을 반복적으로 체크하며 핀의 상태에 따라 해당하는 문자열을 시리얼 포트로 전송합니다.

void loop()

{

 if (digitalRead(buttonPin) == HIGH)

   Serial.write('H');

 else

   Serial.write('L');


 delay(1000);

}

Created with the Personal Edition of HelpNDoc: News and information about help authoring tools and software