Datasheet

Your Shield-Bot’s Brain • Chapter 1
Robotics with the BOE Shield-Bot 27
a = 42;
c = 'm';
root2 = sqrt(2.0);
}
void loop()
{
Serial.println(a);
Serial.println(c);
Serial.println(root2);
delay(1000);
}
Your Turn More Data Types
There are lots more data types than just int, char, float, and byte.
Open the Arduino Language Reference, and check out the Data Types list.
Follow the
float link and learn more about this data type.
The
long data type will be used in a later chapter; open both the long
and
int sections. How are they similar? How are they different?
Activity 4: Solve Math Problems
Arithmetic operators are useful for doing calculations in your sketch. In this activity, we’ll
focus on the basics: assignment (
=), addition (+), subtraction (-), multiplication (*),
division (
/), and modulus (%, the remainder of a division calculation).
Open up the Arduino Language Reference, and take a look at the list of Arithmetic
Operators.
The next example sketch, SimpleMath, adds the variables
a and b together and stores the
result in
c. It also displays the result in the Serial Monitor.
Notice that
c is now declared as an int, not a char variable type. Another point, int c =
a + b
uses the assignment operator (=) to copy the result of the addition operation that
adds
a to b. The next screen capture shows the expected result of 89 + 42 = 131 in the Serial
Monitor.