Comments

/* Comments */

Lets examine this sketch in detail starting with the first section:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the Uno and
  Leonardo, it is attached to digital pin 13. If you're unsure what
  pin the on-board LED is connected to on your Arduino model, check
  the documentation at http://www.arduino.cc

  This example code is in the public domain.

  modified 8 May 2014
  by Scott Fitzgerald
 */

This is a comment, it is text that is not used by the Arduino at all, its only there to help humans like us understand whats going on.

You can see, if something is a comment because there is a /* at the beginning and a */ at the end. Anything between the /* and */ is ignored by the Arduino completely.

In this example the person who wrote the comment decided to make it look pretty and add *'s down the side but this isn't necessary. Heck you could put ¯\_(ツ)_/¯ and other small artworks in there, doesn't matter.

Comments are very useful and I strongly encourage every sketch you make have a comment in the beginning with information like who wrote it, when you wrote it and what it's supposed to do. Future-you will thank present-time-you!

Lets move on to the next section

// One line comments

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

The first line is light gray, and has some English text.

// the setup function runs once when you press reset or power the board

Since you've already experienced seeing light-gray English you might think "Hey this looks a lot like a comment!" And you would be right!

Turns out if you want to make a small comment, you can use // as well as /* */. // is often used for short, one line comments. You can use either style depending on whether you want longer or shorter comment text.

The comment is pretty handy, it tells us that coming up is the setup function, which runs once when you press Reset or power up the board. We'll talk about setup some more later.

For now we'll jump right into your first Arduino statement, so keep reading!

This guide was first published on Sep 02, 2016. It was last updated on Sep 02, 2016. This page (Comments) was last updated on Apr 08, 2020.