Recap of Characters
What We’ve Covered So Far
Declaring a character variable:
char twizzle; // an empty character variable named twizzle for use later
Changing a character variable:
twizzle = 'a'; // twizzle character variable changed to 'a'
Declaring and assigning a character variable at the same time:
char twizzle = 'b'; // character variable named twizzle with a value of 'b'
Doing math with a character variable:
ASCII values: Each character value has a special integer called an ASCII value that corresponds to the character.
twizzle = twizzle + 15; // addition
twizzle = twizzle - 15; // subtraction
twizzle = twizzle * 5; //multiplication
twizzle = twizzle / 2; //division
twizzle ++; //add one to distance
twizzle --; //subtract one from distance
Questions and Activities to Try1. See if you can use the image characters to write a simple story. For example-
3. How about writing your name using just one character variable? You’ll need to do math to the variable between each time you use the sparki.print( ) commands, unless your name only has one letter!
sparki.print(char(2)); // this will code print out a smiley face