Practice: Changing a Comment

Changing Comments

Next, let's do something different. Let's modify a comment. Go down to the last comment, and change it to say "wait for five seconds" like so:

Before we upload this sketch, what do you think the comment change will do to the behaviour of the Arduino and the blinking LED? Take a good guess, then upload the new sketch.

After uploading, what was the change you observed?

There was no change! (Click to reveal answer)

Don't forget: the comments in a sketch do not affect the code itself, they are just your notes and are not converted or sent to the Arduino.

Always have accurate comments

But now you have a comment that does not match the statement. Which should annoy you greatly, like an itch you cannot scratch. Comments should always be accurate.

So! Your job, if you choose to accept it, is to now modify the sketch one more time. This time, you will modify a statement to make it so that the comment is correct.

Before you reveal the answers, try to solve this quest on your own and upload the code to your Arduino to test it out.

Which statement must be modified?

The statement right before the comment:
delay(500);              // wait for five seconds

What needs to be changed?

Instead of delay(500) we should change the input to the delay function into delay(5000) which will make the Arduino wait 5000 milliseconds (5 seconds)

This guide was first published on Sep 02, 2016. It was last updated on Sep 02, 2016. This page (Practice: Changing a Comment) was last updated on Apr 05, 2020.