0Pricing
Arduino & IoT Academy · درس

‏pinMode وOUTPUT

إخبار منفذ بأنه سيقود التيار إلى مصباح LED

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

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

Pins Have a Job

Every Arduino pin can either listen or speak. Before you use one, you must tell it which job to do. That setup is the role of pinMode. 🔌

Why OUTPUT Mode

To light an LED, the pin must send current out into the world. You declare that intent by setting the pin to OUTPUT mode.

The pinMode Call

You configure a pin once, inside setup(). The pinMode function takes a pin number and a mode, and it remembers your choice.

pinMode(13, OUTPUT);

Naming Your Pin

Hard-coded numbers get confusing fast. Give the pin a clear name with a constant so your sketch reads like plain language.

const int ledPin = 13;

Set It Up Once

You only need to declare a pin's mode a single time. Put pinMode in setup(), which runs once when the board powers on.

void setup() {
  pinMode(ledPin, OUTPUT);
}

The Onboard LED

Pin 13 is special: most Arduino boards wire it to a tiny onboard LED. That means you can test output with no extra parts. 💡

A Friendlier Alias

You do not have to memorize the number. Arduino gives you the built-in name LED_BUILTIN, which points to that onboard LED for you.

pinMode(LED_BUILTIN, OUTPUT);

OUTPUT vs INPUT

Each pin defaults to listening. Setting OUTPUT flips it so the pin actively drives a voltage instead of just sensing one.

What 'Drive' Means

An OUTPUT pin can push out about 5 volts or pull down to 0. That controlled push is how a pin drives an LED on or off.

Forgetting pinMode

Skip pinMode and your LED may stay dim or dead. The pin never enters OUTPUT mode, so it cannot push enough current to shine.

Setup Is the Stage

Think of setup() as preparing the stage before the show. Declaring your pin's mode here gets everything ready for the loop that follows.

Quick Check

You want a pin to light an LED. What do you call first?

Recap

You learned to claim a pin with pinMode and OUTPUT inside setup(). With the pin ready to drive current, you can now make it blink. 🎉

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

هل درس «‏pinMode وOUTPUT» مجاني؟

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

ماذا ستتعلم في «‏pinMode وOUTPUT»؟

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

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

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

كم من الوقت يستغرق درس «‏pinMode وOUTPUT»؟

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

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

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

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

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