Hardware Reference
In-Depth Information
sets the color of comments to gray so that it's easy to distinguish from the
actual code (see Example 2-1 ).
Example 2-1. Comments in Arduino code
/*
Everything here is ignored by Arduino's
compiler.
*/
int led = 13 ;
void setup () {
// This is also ignored.
pinMode ( led , OUTPUT );
}
void loop () {
digitalWrite ( led , HIGH ); // This text is ignored as well.
delay ( 1000 );
digitalWrite ( led , LOW );
delay ( 1000 );
}
Take a look at the code in the Blink sketch and see if you can understand what
it's doing by reading the comments. We'll dig deeper into the structure of
Arduino sketches in Chapter 3 .
Try making some changes to the code. For instance, what do you think you
should change to make the LED blink faster? Try changing the code and up-
loading it to the board again.
What happens when you delete a semicolon at the end of a line and try to
upload the code?
What happens when you delete one of the curly brackets and try to upload
the code?
If you're curious, feel free to explore the other examples that come along with
the Arduino IDE!
Search WWH ::




Custom Search