1
SKILL
LEVEL
Ringo Educational Guide Rev04.1 ~ Plum Geek
Code Basics
thisIsCode(); //this part is a comment. This part is ignored by the compiler.
/*
This is a comment block. You can write as much as you want inside a
code block and the comment can take up many lines. You do have to end
a code block eventually with closing characters.
*/
Each sketch includes code and comments. Comments are super important because
they give human readers important notes about what’s going on in the sketch.
Comments are ignored by the Arduino IDE when it compiles the code before
sending it to Ringo’s brain. Comments can be written two ways.
A pair of forward slashes denotes everything else following them on the same line
as a comment, and thus is ignored by the compiler.
But what if your comment is going to require more than one line to write? There’s a
solution for that. You can begin a comment block with a forward slash followed by
a asterisk. Then you can write as many lines of comment as you like. You then end
the comment block with an asterisk followed by a forward slash. Here is an example
of a comment block including the starting and ending characters.
Great. Now let’s talk about the
#include “somefile”
line. This tells the compiler
to copy and paste the referenced file at this point in the code. It is then compiled
in as if you had actually pasted it in this place. This is a good way to include some
external files (which may be really long) at the top of your code without making
your main code window look cluttered.
You’ll learn more about include files eventually. For now, just leave the existing
#include
lines in the examples and be careful not to edit or delete them. If they are
altered, the Arduino IDE may refuse to compile your code sketch.
Code! Yay! Let’s talk about the above example...