0Pricing
Arduino & IoT Academy · درس

التعليقات وsketchs نظيفة

كتابة الملاحظات وتنظيم الشيفرة لتظل مقروءة

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

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

Notes for Humans

Code is read far more often than it is written. Comments are notes you leave so future-you understands the sketch. 📝

The Single-Line Comment

Type two slashes and the rest of that line is a comment. The board ignores it completely when running your code.

// this line is just a note
digitalWrite(13, HIGH);

Comments at Line End

You can drop a comment after real code on the same line. It explains that exact step without breaking anything. Handy for quick context.

delay(1000); // pause for one second

The Block Comment

For longer notes, wrap text between a slash-star and star-slash. This block can span several lines and is great for descriptions.

/* This sketch blinks
   the onboard LED. */

Comments Don't Run

Anything inside a comment is invisible to the board. It is purely for readers, so it never affects how your device behaves.

Explain Why, Not What

Good comments say why a line exists, not just what it does. Note the reason, since the code already shows the action.

delay(20); // debounce noisy button

Indentation Aids Reading

Lines inside braces should be pushed in a few spaces. This indentation shows what belongs together and keeps logic easy to scan.

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

Name Things Clearly

A clear name beats a comment. Calling a pin ledPin instead of just a number tells the reader exactly what it controls.

int ledPin = 13;

Comment Out to Test

Temporarily disable a line by adding slashes in front. Commenting out lets you test without deleting code you might want back.

// digitalWrite(13, LOW);

Avoid Obvious Clutter

Do not narrate every line. A comment like adding one to x adds clutter, not value. Save notes for the parts that truly need explaining.

Clean Sketches Last

Tidy spacing, clear names, and useful comments make a sketch easy to fix months later. Readable code is reliable code.

Quick Check

Let's check what a comment does.

Recap: Clean Sketches

You learned to use comments with // and slash-star, indent inside braces, and name things clearly. Readable sketches stay easy to maintain. 🎉

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

هل درس «التعليقات وsketchs نظيفة» مجاني؟

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

ماذا ستتعلم في «التعليقات وsketchs نظيفة»؟

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

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

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

كم من الوقت يستغرق درس «التعليقات وsketchs نظيفة»؟

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

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

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

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

  1. تشغيل setup() مرة واحدة
  2. تشغيل loop() باستمرار
  3. التعليقات وsketchs نظيفة
  4. أخطاء الترجمة وكيفية قراءتها
← العودة إلى Arduino & IoT Academy