0Pricing
Arduino & IoT Academy · درس

الحركة من 0 إلى 180

حرّك الذراع بسلاسة عبر نطاقه.

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

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

What a Sweep Is

A sweep moves the servo smoothly across its whole range instead of jumping. It's the classic way to see your servo come alive. 🌊

Step by Step

The trick is to step the angle one degree at a time. Each tiny write() nudges the arm a little, and together they look like one smooth motion.

Loop the Angles

A for loop is perfect here. Count from 0 up to 180 and write each value as you go.

for (int a = 0; a <= 180; a++) {
  myServo.write(a);
}

Give It Time

Without a pause the loop finishes before the arm can move. A short delay() lets each step physically happen.

myServo.write(a);
delay(15);

Delay Sets Speed

The delay value controls sweep speed. A bigger number makes a slow, graceful sweep; a smaller one makes it whip across quickly.

Now Come Back

To sweep back, run a second loop that counts down from 180 to 0. Together the two loops make a full there-and-back motion.

for (int a = 180; a >= 0; a--) {
  myServo.write(a);
  delay(15);
}

Put It in loop()

Drop both for loops inside loop() and the servo sweeps back and forth forever, just like the Arduino Sweep example.

Mind the Limits

Stay within 0 to 180. Pushing a standard servo past its stops makes it buzz and strain, which wears out the gears.

Skip Steps to Hurry

Want a faster sweep without a tiny delay? Increase the step size by counting up by 5 instead of 1.

for (int a = 0; a <= 180; a += 5) {
  myServo.write(a);
  delay(20);
}

Park in the Middle

Before doing real work, many projects center the servo at 90 degrees first. It's a tidy, known starting position.

myServo.write(90);

Smooth vs Snappy

Sweeping is gentle on the gears, but sometimes you want a fast snap to a target. Pick smooth or snappy based on your project's feel.

Quick Check

Let's see why a sweep needs a pause between steps.

Recap

Step the angle in a for loop with a small delay, then loop back down. That up-and-down pattern is the full servo sweep. 🔁

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

هل درس «الحركة من 0 إلى 180» مجاني؟

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

ماذا ستتعلم في «الحركة من 0 إلى 180»؟

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

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

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

كم من الوقت يستغرق درس «الحركة من 0 إلى 180»؟

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

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

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

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

  1. كيف يعرف Servo زاويته
  2. مكتبة Servo وattach
  3. الحركة من 0 إلى 180
  4. Servo يتحكم فيه مقبض
← العودة إلى Arduino & IoT Academy