Datasheet
Your Shield-Bot’s Brain • Chapter 1
Robotics with the BOE Shield-Bot • 39
Projects
1. Write a sketch to display the printable ASCII characters. The first printable
character is the space character, which is one press/release of your keyboard’s
space bar between apostrophes, like this: ‘ ’. The last printable character is the
tilde character ‘~’. Alternately, you could use 32 for the loop’s start value and
126 for the end value.
2. Write a sketch that tells you if a variable is odd or even. Hint: when a number is
even, the remainder of the number divided by 2 is 0. Hint: variable % 2 == 0.
Question Solutions
1. The Arduino module.
2. Binary numbers, that is, 0’s and 1’s. We also saw examples of how the numbers
that represent characters are ASCII codes, like 109 = ‘m’.
3. The
setup function’s statements get executed once when the sketch starts. After
finishing the
setup function, the sketch advances to the loop function. Its code
block gets repeated indefinitely.
4. The variable’s name is used for assignment and comparison in the sketch. The
variable’s type defines the kind and range of values it can store.
5. Global variables can be accessed and modified by any function in the sketch.
Local variables can only be accessed and modified within the block where they
are declared.
6. The arithmetic operators are
+ add, - subtract, * multiply, / divide, and %
modulus.
7. It will be treated as a
float type because it has a decimal point.
8. Initialization, condition, increment.
9. A block comment starts with
/* and ends with */, and allows you to write
comments that span multiple lines. A line comment starts with
// and makes
whatever is to its right on that particular line a comment.
Exercise Solutions
1. Solution:
Serial.print("the value of i = ");
Serial.println(i);
2. Solution:
long bigVal = 80000000;