Datasheet

Your Shield-Bot’s Brain • Chapter 1
Robotics with the BOE Shield-Bot 21
Serial.print(val); passes the message “Hello!” to the val parameter. This tells the
Arduino to send a series of binary ones and zeros to the Serial Monitor. The monitor decodes
and displays that serial bitstream as the “Hello!” message.
After the
setup function is done, the Arduino automatically skips to the loop function and
starts doing what the statements in its curly braces tell it to do. Any statements in
loop will
be repeated over and over again, indefinitely. Since all this sketch is supposed to do is print
one "Hello!" message, the
loop function doesn’t have any actual commands. There’s just a
notation for other programmers to read, called a comment. Anything to the right of
// on a
given line is for programmers to read, not for the Arduino software’s compiler. (A compiler
takes your sketch code and converts it into numbersa microcontroller’s native language.)
What is void? Why do these functions end in ()? The first line of a function is its definition, and
it has three parts: return type, name, and parameter list. For example, in the function void
setup
() the return type is void, the name is setup, and the parameter list is empty there’s
nothing inside the parentheses (). Void means ‘nothing’—when another function calls setup
or loop, these functions would not return a value. An empty parameter list means that these
functions do not need to receive any values when they are called to do their jobs.
Code block
contained in
curly braces { }
void setup()
{
Serial.begin(9600);
Serial.print("Hello!");
}
setup function
Statements
Function
definition
Comment for
you and other
coders to read
void loop()
{
// Add code that repeats automatically here.
}