Comments
A sketch is the name of a program file for the Arduino. It is the code (such as the Blink example) that you compile and upload into the Arduino.
Read the following information from this useful Arduino guide on Sketches:
"The first few lines of the Blink sketch are a comment:
/*
Blink
The basic Arduino example. Turns on an LED on for one second,
then off for one second, and so on... We use pin 13 because,
depending on your Arduino board, it has either a built-in LED
or a built-in resistor so that you need only an LED.
http://www.arduino.cc/en/Tutorial/Blink
*/
Everything between the */
is ignored by the Arduino when it runs the sketch.
It's there for people reading the code: to explain what the program does, how it works, or why it's written the way it is.
It's a good practice to comment your sketches, and to keep the comments up-to-date when you modify the code. This helps other people to learn from or modify your code. There's another style for short, single-line comments. These start with // 1. Open the Blink example sketch (refer to this guide if you need a refresher.) 2. Add two slash marks (//) to the start of the line with the pinMode statement (line of code) and upload the code again. Observe what is different. 2.1. With the modification you just made, does the LED turn on brightly or dimly? 2.2. The symbols for a single-line comment are . 2.3 Note that you can also use CTRL+/ to comment/uncomment the line of code where your cursor is. Try this now. 4. Uncomment (delete the comment marks) to restore the missing line of code. 6.1. Open a multi-line comment with the symbol and close it with the symbol In the Arduino programming environment, how do you insert comments? Answer format: numbers separated by commas and spaces, like "2, 4" (not actual answer) In the Arduino IDE (Integrated Development Environment), what is the purpose of using comments? Answer format: numbers separated by commas and spaces, like "2, 4" (not actual answer)and continue to the end of the line. For example, in the line:
int ledPin = 13; // LED connected to digital pin 13
Commenting Out Code
Warning: Arduino is case sensitive so be careful with your capitals.
3. You have just commented out a line of code. Comment out code rather than delete it if you think you may use the code again later.
4.1. Note that you can also use CTRL+/ to comment/uncomment any lines of code you have selected. Try this now.
5. Upload it and observe the results.
5.1. Based on your observations, the function to let an LED turn on full power instead of dimly in the Blink example is named (remember that Arduino is case sensitive).
6.2. Based on your observations and reading the comments in the Blink example, the function to turn an LED on or off in the Blink example is named . Turn the LED on by setting it . Turn the LED off by setting it .