What is a comment is used for? How to use them?

The comments are the only text the programming language that are not going to be compiled by the compiler. They can be used to a better understand of your code, to easily read it.

The comments can be also used to not a execute a part of a program, to try an instruction for example.

  • Comment one line

We will see how to comment one line on the Arduino language. To do that we use double slash that way:

int count =0; // Your comment

The double slash can be also used to comment a command line, to make a test for example:

// int count =0;  This line is a comment

Nevertheless it is possible that you need to comment multiple lines. To do that we will use an another instruction.

  • Comment multiple lines

To comment multiple lines, we will star slash:

/*This is a comment */
/* 

This is another comment */

As you have seen, thank to the slash star you can comment one or more lines.

We will see now an example in which we comment multiple lines:

void setup(){
Serial.begin(9600);
 /* This is the beginning of the comment of multiple lines 
int count = 0; 
do {
  delay(50);          
  count+=1;  
  Serial.println(count); 
} while (count < 100); 
 End of the comment*/ 
}
void loop(){
}

The storage of the system on chip

The lines of the comment are ignored by the compiler, that’s mean it doesn’t take more storage in the memory of the system on chip.