Карлсон
Оракул
(65591)
7 лет назад
Так ты в отладке посмотри что у тебя в коде творится. Что за millis?
Используй sleep(value);
int getCurrentTime(){
SYSTEMTIME time;
GetSystemTime(&time);
return (time.wSecond * 1000) + time.wMilliseconds;
}
void timer(int delay){
int startTime = getCurrentTime();
while (startTime + delay > getCurrentTime());
return;
}
вот код:
bool timer(int zaderjka)
{
static unsigned long previousMillis = 0;
if(millis() - previousMillis > zaderjka) {
previousMillis = millis();
return true;
}
else { return false;}
}
Вот вызов :
if(timer(5000) == true) {
Serial.println('1');
}
if(timer(10000) == true) {
Serial.println('2');
}
if(timer(1000) == true) {
Serial.println(millis()); //выполняется только эта часть
}