0Pricing
Arduino & IoT Academy · درس

‏digitalWrite HIGH وLOW

تشغيل المنفذ وإيقافه لإضاءة مصباح LED

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

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

Now Make It Glow

Your pin is set to OUTPUT, but it is still silent. To actually switch it on or off, you use one new command: digitalWrite. ✨

Two States Only

A digital pin lives in just two states. It is either fully on, called HIGH, or fully off, called LOW. There is nothing in between.

HIGH Means On

Writing HIGH pushes the pin up to roughly 5 volts. That voltage flows through your LED and lights it. HIGH is the on signal.

digitalWrite(ledPin, HIGH);

LOW Means Off

Writing LOW drops the pin back to 0 volts. With no voltage to push current, the LED goes dark. LOW is the off signal.

digitalWrite(ledPin, LOW);

The Two Arguments

digitalWrite needs two things: which pin to change, and the state to set. So you pass a pin and then either HIGH or LOW.

digitalWrite(pin, HIGH);

It Belongs in loop

You set a pin's mode once, but you can change its state any time. Put digitalWrite in loop() to switch the LED on demand.

On Then Off

To blink, you simply alternate. Drive the pin HIGH, then drive it LOW, and the LED toggles between glowing and dark.

digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);

Too Fast to See

Run HIGH then LOW with nothing between and the LED flickers far too fast for your eyes. You need a pause, which comes next lesson.

1 and 0 Also Work

HIGH and LOW are just friendly names. Under the hood they equal 1 and 0, so digitalWrite(pin, 1) does the same as HIGH.

Read Back the State

digitalWrite changes a pin but never reports it. To check what an output pin is doing, you track the state yourself in a variable.

Mind the Wiring

The onboard LED needs no parts, but an external one can pull too much current. Always protect it with a resistor, covered soon.

Quick Check

Your LED is connected and the pin is OUTPUT. How do you turn it off?

Recap

You now control a pin with digitalWrite, using HIGH for on and LOW for off. Next you will add timing so the blink is actually visible. 🎉

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

هل درس «‏digitalWrite HIGH وLOW» مجاني؟

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

ماذا ستتعلم في «‏digitalWrite HIGH وLOW»؟

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

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

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

كم من الوقت يستغرق درس «‏digitalWrite HIGH وLOW»؟

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

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

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

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

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