ببینید همون کاری رو که دیلی انجام میدید دقیقا میشه با میلیس انجام داد با این تفاوت که دیگه پروسسور توی خط دیلی توقف نمیکنه
میره کاراشو انجام میده وقتی زمانی که ما براش تعیین کردیم رسید شرط if رو اجرا می کنه :
کد:
const int ledPin = 13; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 1000; // interval at which to blink (milliseconds)
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
}
توی این کد داره میگه ه1 یک ثانیه یک بار ال ای دی شماره 13 روشن و خاموش بشه
شما می تونید از این کد الهام بگیرید