키위백과의 잡동사니

FUNCTIONS : millis() 본문

아두이노/참조(Reference)

FUNCTIONS : millis()

KiwiPedia 2018. 5. 4. 16:00

millis()

 

설명(Description)

Arduino 보드가 현재 프로그램을 실행한 후 밀리 초를 반환합니다. 이 숫자는 약 50일 후에 0이 됩니다.

 

문법(Syntax)

time = millis()

 

파라미터(Parameters)

없음.

 

반환(Returns)

프로그램 시작 후 ms 수(unsigned long)

 

예제 코드(Example Code)

이 코드는 Arduino 보드가 시작된 이후 ms(milliseconds)를 읽습니다.

unsigned long time;

void setup(){
  Serial.begin(9600);
}
void loop(){
  Serial.print("Time: ");
  time = millis();

  Serial.println(time);    //prints time since program started
  delay(1000);             // wait a second so as not to send massive amounts of data
}

 

메모 및 주의(Notes and Warnings)

millis()의 반환 값은 unsigned long이므로 프로그래머가 int와 같은 작은 데이터 유형으로 산술을 수행하려고 하면 논리 오류가 발생할 수 있습니다. 또한, signed long 최대값은 unsigned long 최대값의 절반이므로 오류가 발생할 수 있습니다.

'아두이노 > 참조(Reference)' 카테고리의 다른 글

아두이노 참조 번역 중단  (0) 2019.02.08
FUNCTIONS : micros()  (0) 2019.02.08
FUNCTIONS : delay()  (0) 2018.05.04
FUNCTIONS : digitalWrite()  (0) 2018.05.03
FUNCTIONS : pinMode()  (0) 2018.05.02
Comments