Datasheet
Chapter 1 • Your Shield-Bot’s Brain
20 • Robotics with the BOE Shield-Bot
Choose Open from this menu to re-open your sketch. Or, navigate to the un-
zipped example code archive you downloaded previously to open sketches used
in this book.
How the Hello Sketch Code Works
A function is a container for statements (lines of code) that tell the Arduino to do certain
jobs. The Arduino language has two built-in functions:
setup and loop.
The
setup function is shown below. The Arduino executes the statements you put between
the
setup function’s curly braces, but only once at the beginning of the sketch.
In this example, both statements are function calls to functions in the Arduino’s built-in, pre-
written Serial code library:
Serial.begin(speed) and Serial.print(val). Here, speed
and
val are parameters, each describing a value that its function needs passed to it to do its
job. The sketch provides these values inside parentheses in each function call.
Serial.begin(9600); passes the value 9600 to the speed parameter. This tells the
Arduino to get ready to exchange messages with the Serial Monitor at a data rate of 9600
bits per second. That’s 9600 binary ones or zeros per second, and is commonly called a baud
rate.
Run the sketch
Check your code
Open the Serial Monitor
Baud rate in sketch and in Serial
Monitor must match!
Select your board
Choose your COM port
Heads-up for Chrome users!
The Serial Monitor displays the
text in your code
Save your code