0Pricing
Arduino & IoT Academy · درس

‏delay() وتوقيت الوميض

إيقاف التنفيذ مؤقتًا لصنع إيقاع وميض مرئي

‏delay() وتوقيت الوميض درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Add a Pause

Switching a pin on and off happens in microseconds, far too fast to see. To make a real blink, you tell the board to wait with delay. ⏱️

delay Speaks Milliseconds

The delay function pauses your sketch for a number of milliseconds. One second is 1000 of them, so delay(1000) waits one full second.

delay(1000);

Freeze the Light On

Turn the LED HIGH, then call delay. The board sits still and the LED stays lit for the whole pause before doing anything else.

digitalWrite(ledPin, HIGH);
delay(1000);

Then Hold It Off

Now drive the pin LOW and delay again. The LED stays dark for that pause, giving the off half of your blink its own visible moment.

digitalWrite(ledPin, LOW);
delay(1000);

The Full Blink Loop

Stack those four lines inside loop() and you get a steady blink: on, wait, off, wait, repeat. That is the classic Blink sketch.

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}

Faster or Slower

Change the number to change the rhythm. A smaller value like delay(200) makes a quick flash, while a larger one slows the blink right down.

delay(200);

On and Off Can Differ

The two delays do not have to match. A long on-time and short off-time gives a steady glow with a brief wink between pulses.

delay Stops Everything

Here is the catch: during a delay the board does nothing else. It cannot read a button or sensor, because delay blocks the whole sketch.

Fine for Now

For a simple blink, blocking is fine. Later you will meet millis, a way to time events without freezing the rest of your program.

Tiny vs Big Waits

delay handles milliseconds, but for very short pauses there is delayMicroseconds. You will need it later for precise sensor timing.

Loop Does the Repeating

You never write a repeat command. Because loop() runs again automatically, your on-off-wait pattern repeats forever on its own.

Quick Check

You want the LED to stay on for exactly two seconds.

Recap

You used delay to pace your blink, learned it counts milliseconds, and saw that it blocks everything else. Next you will wire a real LED. 🎉

الأسئلة الشائعة

هل درس «‏delay() وتوقيت الوميض» مجاني؟

نعم — نص درس «‏delay() وتوقيت الوميض» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

ماذا ستتعلم في «‏delay() وتوقيت الوميض»؟

إيقاف التنفيذ مؤقتًا لصنع إيقاع وميض مرئي تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟

لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «‏delay() وتوقيت الوميض»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟

نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ‏pinMode وOUTPUT
  2. ‏digitalWrite HIGH وLOW
  3. ‏delay() وتوقيت الوميض
  4. توصيل مصباح LED خارجي بأمان
← العودة إلى Arduino & IoT Academy