-
Arduino digitalRead() 반응속도아두이노 2021. 4. 1. 15:50
02.Digital_Button
Button
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
www.arduino.cc
button 예제는 2번 pin 에 button 을 연결하고 button 값이 1 이면 LED on, button 값이 0 이면 LED off 가 된다.
// constants won't change. They're used here to set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } }
digitalRead() 의 반응속도는 어느정도일까??
channel 1 = Button 입력 (2번핀)
channel 2 = digitalWrite 출력 (13번핀)
channel 2 가 여러번 찍히는 것으로 보아 button 입력을 처리하는 시간이 일정하지 않다.
가장 빠른 응답은
digitalRead() + digitalWrite() = 6.5 us
이전 실험에서 digitalWrite() 가 5.5 us 였으니, digitalRead() 는 1 us 정도의 연산시간을 가지는 걸 알수있다.
가장 느린 응답은
digitalRead() + digitalWrite() = 16.1 us
'아두이노' 카테고리의 다른 글
Touch Sense Key Matrix (HW-136 , 8229BSF) (0) 2021.04.06 Arduino digitalWrite() 반응속도 (0) 2021.03.31 Arduino Mega 2560 회로정리 (0) 2021.03.31