Recap of Characters
What We’ve Covered So Far
Declaring a character variable:
1 |
char twizzle; // an empty character variable named twizzle for use later |
Changing a character variable:
1 |
twizzle = 'a'; // twizzle character variable changed to 'a' |
Declaring and assigning a character variable at the same time:
1 |
char twizzle = 'b'; // character variable named twizzle with a value of 'b' |
Doing math with a character variable:
1 2 3 4 5 6 |
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 Try
1. See if you can use the image characters to write a simple story. For example- 2. Using the LCD code we covered try using the command sparki.print( ) instead of sparki.println( ). See if you can spell your name out by creating a bunch of different character variables with letter stored in them. What about doing it with ASCII values inside the sparki.print( ) commands instead of letters? (Hint, you’ll need to change the numbers in to characters kind of like how we changed the characters into a number above. An example of that code is shown below.)
1 |
sparki.print(char(2)); // this will code print out a smiley face |