Datasheet
Your Shield-Bot’s Brain • Chapter 1
Robotics with the BOE Shield-Bot • 25
One nice thing about variable types is that
Serial.println recognizes each type and
displays it correctly in the Serial Monitor. (Also, the C++ compiler in the Arduino software
requires all declared variables to have a type, so you can’t leave it out.)
Example Sketch – StoreRetrieveLocal
Create a new sketch, and save it as StoreRetrieveLocal.
Open or create and save the StoreRetrieveLocal sketch, and run it on your
Arduino.
Open the Serial Monitor and verify that the values display correctly.
// Robotics with the BOE Shield - StoreRetrieveLocal
void setup()
{
Serial.begin(9600);
int a = 42;
char c = 'm';
float root2 = sqrt(2.0);
Serial.println(a);
Serial.println(c);
Serial.println(root2);
}
void loop()
{
// Empty, no repeating code.
}
ASCII stands for American Standard Code for Information Exchange. It’s a common code system
for representing computer keys and characters in displays. For example, the declaration char c
= 'm'
makes the Arduino store the number 109 in the c variable. Serial.println(c) makes
the Arduino send the number 109 to the Serial Monitor. When the Serial Monitor receives that
109, it automatically displays the letter m. See http://learn.parallax.com/ascii
for codes 1-127.
Serial.println(a);
Serial.println(c);
Serial.println(root2);