Comments & Clean Sketches
Write notes and structure so code stays readable.
Comments & Clean Sketches is a free Arduino & IoT Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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 secondThe 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 buttonIndentation 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. 🎉
Frequently asked questions
Is the “Comments & Clean Sketches” lesson free?
Yes — the full text of “Comments & Clean Sketches” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “Comments & Clean Sketches”?
Write notes and structure so code stays readable. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Comments & Clean Sketches” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- setup() Runs Once
- loop() Runs Forever
- Comments & Clean Sketches
- Compile Errors & How to Read Them