0Pricing
Arduino & IoT Academy · درس

توصيل زر على لوحة تجارب

توصيل زر ضغط بطريقة منظمة مع مقاومة سحب

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

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

Time to Build It

You've written the code; now make it real. You'll wire a push button on a breadboard so the Arduino can actually feel your press.

Meet the Push Button

A tactile push button has four legs, but they're really just two pairs. Pressing it connects one pair to the other inside.

Mind the Center Gap

Straddle the button across the breadboard's center gap. That keeps the two sides separate until a press bridges them together.

Lean on the Internal Pull-Up

Thanks to INPUT_PULLUP, you skip the external resistor entirely. The board holds the pin HIGH for you, so wiring stays tiny.

One Leg to the Pin

Run a jumper from one button leg to a digital pin, say pin 2. This is the line the Arduino will read for presses.

Other Leg to Ground

Connect the opposite leg to GND. When you press, the pin gets pulled down to ground and your code sees LOW.

Use the Diagonal Legs

Because the legs are paired, wire to ones that sit diagonally across the button. That guarantees you bridge the two real contacts.

Power Off While Wiring

Unplug the USB before moving wires. Building with the board powered off avoids shorts and protects the Arduino from mistakes. 🔋

Match Code to Wiring

Your sketch must name the same pin you wired. Set pin 2 to INPUT_PULLUP so the software and the hardware agree.

void setup() {
  pinMode(2, INPUT_PULLUP);
}

Test with Serial

Upload, open the Serial Monitor, and press. Seeing the value drop to 0 confirms your button and wiring both work.

Troubleshoot Calmly

No change on press? Check the diagonal legs, confirm the GND wire, and make sure the code uses the exact pin you plugged into.

Quick Check

Think about where the button's two legs should connect.

Recap

You wired a button across the center gap, one leg to pin 2 and one to GND, then confirmed it on Serial. You can now sense the real world! 🎉

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

هل درس «توصيل زر على لوحة تجارب» مجاني؟

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

ماذا ستتعلم في «توصيل زر على لوحة تجارب»؟

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

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

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

كم من الوقت يستغرق درس «توصيل زر على لوحة تجارب»؟

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

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

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

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

  1. ‏INPUT مقابل INPUT_PULLUP
  2. قراءة حالة زر
  3. ‏if/else: مصباح LED يتبع الزر
  4. توصيل زر على لوحة تجارب
← العودة إلى Arduino & IoT Academy