لماذا ترتد الأزرار
شاهد الإشارات الكاذبة التي ينشئها التلامس.
لماذا ترتد الأزرار درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
One Press, Many Signals
You press a button once, but your Arduino may see several presses. This sneaky problem is called bounce, and it trips up almost every beginner. 😅
Inside a Push Button
A button is just two metal contacts that touch when you press. They feel solid to your finger, but at the microsecond level they are anything but.
Metal That Chatters
When the contacts meet, they physically vibrate for a few milliseconds before settling. Each tiny touch and break is a separate electrical event.
What the Pin Sees
During that vibration, the pin reads a burst of rapid HIGH-LOW flips instead of one clean change. Your code can count every flip as a press.
Why the Loop Catches It
Your loop() runs millions of times per second, far faster than the bounce settles. So it samples the noise again and again.
A Counter Gone Wild
Picture a counter that adds one per press. One real tap can jump it by three or four because of multiple false triggers.
if (digitalRead(BTN) == LOW) {
count++; // may fire several times per tap
}It Happens on Release Too
Bounce strikes when you let go as well, not just when you press. Both edges of the signal can stutter and confuse your logic.
How Long It Lasts
Most bounce settles within about 5 to 20 milliseconds. It is brief, but to a fast microcontroller that is an eternity of noise.
Spot It Yourself
Print a message every time the pin goes LOW and tap once. Seeing several lines in the Serial Monitor proves bounce is real.
if (digitalRead(BTN) == LOW)
Serial.println("pressed");Hardware or Software Fix
You can tame bounce with a small capacitor in the circuit, or with timing logic in code. Software is cheaper and far more common.
The Core Idea
The fix is to wait briefly after the first change and ignore the rest. Confirm the button is truly stable before you act on it.
Quick Check
Let's confirm what causes a button to bounce.
Recap: Bounce Basics
You learned that a button's contacts bounce, sending noisy flips that fool fast code. Next you'll silence that noise with simple timing. 🎯
الأسئلة الشائعة
هل درس «لماذا ترتد الأزرار» مجاني؟
نعم — نص درس «لماذا ترتد الأزرار» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.
ماذا ستتعلم في «لماذا ترتد الأزرار»؟
شاهد الإشارات الكاذبة التي ينشئها التلامس. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟
لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «لماذا ترتد الأزرار»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟
نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- لماذا ترتد الأزرار
- إزالة ارتداد الإشارة باستخدام millis()
- تخزين قيمة في EEPROM
- تذكّر العداد بعد إعادة الضبط