Hardware Reference
In-Depth Information
Although it may appear that the Arduino has simply run your program, it
hasn't done only that. Arduinos contain something called a bootloader , a small
program that is run every time the device starts. This is only one of the strong
points of the Arduino system; the bootloader is always available to allow the
programmer to rel ash a program. Even if you accidentally l ash a program that
continuously crashes, you will always be able to rel ash your Arduino, provided
the bootloader is present.
WARNING If you need more program space, you can delete the bootloader and
place your own application at the start of the processor's instruction sequence. Doing
this has the advantage of freeing the space used by the bootloader and using it for
your own application. The bootloader is a small program, about 2 kilobytes in size.
If you delete the bootloader, you can still refl ash your Arduino, but more specialized
equipment will be required.
Understanding Your First Sketch
Now that your sketch works and you have seen the results, it is time to have a
closer look at the source code. This is presented step by step. The i rst part gives
some interesting information:
/*
Blink
Turns on an LED on for one second, then off for one second repeatedly
This example code is in the public domain.
*/
Everything placed between the text /* and */ is considered to be a comment ,
a portion of source code that is ignored by the compiler. Everything within
these markers will be ignored, so it is the best place to write natural language
text about what the program does, or is doing. It is common to start a source
code i le with a comment, explaining what the application does. Just by looking
at these few lines, you already have an idea about what the program will do.
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
This, again, explains what will happen using comments. Just like the /* and
*/ markers, when the compiler encounters the marker // , it will ignore every-
thing else after that marker but only for that line. On the i rst line, the compiler
encounters a comment marker and ignores the text. It then attempts to read in
 
Search WWH ::




Custom Search