Comentarios y sketches limpios
Escriba notas y estructure el código para que siga siendo legible
Comentarios y sketches limpios es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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. 🎉
Preguntas frecuentes
¿La lección «Comentarios y sketches limpios» es gratis?
Sí — el texto completo de «Comentarios y sketches limpios» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Comentarios y sketches limpios»?
Escriba notas y estructure el código para que siga siendo legible Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Arduino & IoT Academy?
No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.
¿Cuánto tiempo toma la lección «Comentarios y sketches limpios»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?
Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- setup() se ejecuta una vez
- loop() se ejecuta para siempre
- Comentarios y sketches limpios
- Errores de compilación y cómo leerlos