Datasheet

Chapter 1 Your Shield-Bot’s Brain
38Robotics with the BOE Shield-Bot
Using operators in if statements
How to count and control repetitions with
for and while loops
Computer Skills
What a baud rate is, and how to set it in your sketch and your Serial Monitor
What ASCII characters are, and what they are used for
Using your microcontroller’s language reference
Why documenting code is important, and how to help make your code self-
documenting
Chapter 1 Challenges
Questions
1. What device will be the brain of your BOE Shield-Bot?
2. When the Arduino sends a character to your computer, what type of numbers are
used to send the message through the programming cable?
3. What is the difference between the
setup and loop functions?
4. What’s the difference between a variable name and a variable type?
5. What’s the difference between global and local variables?
6. What are the arithmetic operators? What does each one do?
7. What variable type will the Arduino editor apply to 21.5 if it appears in your
code? Why?
8. What three elements are included between parentheses in a
for loop?
9. What’s the difference between a block comment and a line comment?
Exercises
1. Write a piece of code that displays “the value of i = ” followed by the value of
stored in the variable
i in the Serial Monitor. Both should display on the same
line, and then move the cursor to the beginning of the next line for displaying
more messages.
2. Declare a
long variable named bigVal, and initialize it to 80 million.
3. Write an
if…else statement that takes the modulus of a variable divided by 2
and compares it to zero. If the result is zero, display “The variable is even.” If not,
display “The variable is odd.”
4. Write a
for loop that starts counting at 21 and stops at 39, and counts in steps of
3.
5. Write a piece of code that displays the character stored by a variable stores along
with its ASCII value.
6. Write a
for loop, but instead of counting from one value to another, make it
count from 'A' to 'Z' and display the letters in the alphabet.