회로도전자부품

아두이노 시간함수 BlinkWithoutDelay 함수

by nanumi posted Jun 26, 2019
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

아두이노 시간함수 BlinkWithoutDelay 함수

 

 

const int relayinputpin = 12;

int relayinputState = low;

 

unsigned long previousMillis = 0;

const long interval = 1000;

 

void setup() {

pingMode(relayinputpin, OUTPUT);

}

 

void loop() {

unsigned long currentMillis = millis();

 

if(currentMillis - previousMillis >= interval) {

previousMillis = currentMillis;

 

if(relayinputState == LOW)

relayinputState = HIGH;

else

relayinputState = LOW;

 

digitalWrite(relayinputpin, relayinputState);

}

}