Schedule‎ > ‎

05A: Old, Redundant, Not used

Questions, Answers and Review

  • Questions from last class?
  • Questions about homework?

^ top

Characters and Strings

Learner Outcomes

At the end of the lesson the student will be able to:

  • Identify characters and strings from their literal representation
  • Assign characters and strings to variables
  • Call commonly used String functions
  • Compare characters and strings

^ top

Type char

  • In addition to numbers, computers can manipulate text and other non-numerical types
  • Values of type char (short for character) are a single letter, number or special symbol
  • We specify a character by enclosing it in single quotes (")
    • The quote marks are not part of the data
  • For example:
    'a'   'b'   'Z'   '3'   'q'   '$'   '*'

ASCII Code

  • When we use a char data type, we store the character using a code known as ASCII
  • ASCII, which is an acronym for American Standard Code for Information Interchange, assigns a number to every character
  • Remember that computers store only numbers
  • So to handle text, each character is assigned a number as shown below
  • Each character requires 7-bits, which means it fits within one byte
  • ASCII was the first standardized code but is limited to English
  • However, ASCII has been extended to include all languages
  • The extended ASCII code is called Unicode

Table of ASCII Codes

ASCII table

Source: imageKB.com

Declaring and Assigning char Variables

  • As with other data types, we must declare char variables before use:
    char letterA;
  • We assign values to a char variable using the equals sign:
    letterA = 'A';
  • Just like numerical types, we can combine declaration and assignment into one statement:
    char letterB = 'B';
  • C++ allows us to assign ASCII code numbers to char variables as well
    char letterC = 67;
    char letterD = letterC + 1;
    

Example Code with char Variables

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void setup() {
  Serial.begin(9600);
  char letterA;
  letterA = 'A';
  Serial.print(letterA);
  char letterB = 'B';
  Serial.print(letterB);
  char letterC = 67;
  Serial.print(letterC);
  char letterD = letterC + 1;
  Serial.println(letterD);
  Serial.println("Enter some characters");
}

void loop() {
  if (Serial.available()) {
    char code = Serial.read();
    if (10 == code) {
      Serial.println("Line feed");
    } else if (13 == code) {
      Serial.println("carriage return");
    } else {
      Serial.println(code);
    }
  }
}

Serial I/O with Type char

  • Like numbers, we can output type char using Serial.print() or Serial.println()
    char letter = 'A';
    Serial.print(letterA);
    Serial.println('B');
    
  • Also, we can input type char using Serial.read()
    char letter = Serial.read();
    Serial.println(letter);
    

Check Yourself

  1. The type of delimiter used to enclose single characters of type char is the ________.
  2. The correct data type for a single character is ________.
    1. character
    2. char
    3. text
    4. string
  3. Which of the following correctly declares a variable for a single character and assigns it a value?
    1. char var = 'z';
    2. char var = 122;
    3. char var = "z";
    4. char var = 'a' + 25;
  4. True or false: we can display a single ASCII character with Serial.println().

More Information

  • ASCII: Video introduction from Harvard CS50.tv on YouTube

^ top

Introduction to Strings

  • In addition to single characters, computers can work with text strings
  • For example, in the following the characters between the double quotes are displayed as text:
    Serial.println("Hello World!");
    
  • Programmers refer to text like this as a string because it is composed of a sequence of characters that we string together
  • Strings are enclosed in double quotes, which are not part of the string
  • For example:
    "Hello"  "b"  "3.14159"  "$3.95"  "My name is Ed"
  • Notice that the string "3.14159" could be expressed as a double by removing the quotes
  • However, a computer stores these two values very differently and we must use them in different ways
  • For instance, we cannot multiply the "3.14159" by 2, but we can when it is expressed as a double:
    Serial.println("3.14159" * 2); // NO!
    Serial.println(3.14159 * 2); // allowed
    

String Variables and Serial I/O

  • We declare and assign values to String variables like numeric and character types
  • For example:
    String firstName;             // declaration
    firstName = "Edward";         // assignment
    String lastName = "Parrish";  // declaration + assignment
    Serial.print(firstName);
    Serial.print(" ");
    Serial.println(lastName);
    

Serial I/O with Strings

  • Like numbers and characters, we can output type String using Serial.print() and Serial.println()
  • Also, we can input a string by calling Serial.readString() as shown below

Example of Serial I/O with Strings

1
2
3
4
5
6
7
8
9
10
11
12
void setup() {
  Serial.begin(9600);
  Serial.println("Enter your name.");
}

void loop() {
  if (Serial.available()) {
    String name = Serial.readString();
    Serial.print("You entered: ");
    Serial.println(name);
  }
}

Check Yourself

  1. True or false: use a String variable rather than a char variable when you need to store more than one character.
  2. The type of delimiters used to enclose strings is the ________
  3. True or false: "A" and 'A' are the same.
  4. True or false: we can perform arithmetic operations on strings.
  5. Which of the following is the correct way to declare a string variable named myString and assign it the text "Hi Mom!"?
    1. string myString = Hi Mom!;
    2. string myString = "Hi Mom!";
    3. String myString = "Hi Mom!";
    4. String myString = "Hi Mom"!
  6. Which of the following is the correct way to input text from the serial port and store it in a previously declared variable named myWord?
    1. myWord = serial.readString();
    2. myWord = Serial.read();
    3. myWord = Serial.readString();
    4. myWord = Serial.parseInt();

More Information

^ top

Output of Hard-to-Print Characters

  • We have been using Serial.print() and Serial.println() to output strings
  • However, some strings are more difficult to output than others
  • For example, what if we wanted to output: Say, "Hey!"
  • We could write a statement like:
    Serial.println("Say, "Hey!"");
    
  • How would the compiler treat the double-quote marks (") in the statement?
  • Some characters cannot be output directly in a string
  • Also, the first 32 ASCII characters are old Teleprinter control characters
  • Some control characters are still used today such as newline characters
  • We need some way to output characters like control codes and double quotes (")

Escape Sequences

  • C++ can print control codes and some hard-to-print characters using escape sequences
  • A backslash (\) directly in front of some characters tell the compiler to escape from the normal interpretation
  • The following table lists some common nonprinting and hard-to-print characters supported by the Serial Monitor
Sequence Meaning
\n New line
\t Horizontal tab
\\ Backslash
\' Single quote
\" Double quote
\ooo ASCII character in octal notation
\xhhh ASCII character in hexadecimal notation

Examples of Escape Sequences Supported by the Serial Monitor

1
2
3
4
5
6
7
8
9
void setup() {
  Serial.begin(9600);
  Serial.println("Say, \"Hey!\"");
  Serial.println("one\ntwo\x00Athree");
  Serial.println("Left\tRight");
}

void loop() {
}

Check Yourself

  1. True or false: an escape sequence is a series of characters that does not represent itself but is translated into a character code.
  2. Which of the following is an escape sequence?
    1. "/n"
    2. "/t/n/t"
    3. "\n\t\""
    4. "/\n"
  3. Which of the following is a correct way to print: Say, "Hey"!?
    1. Serial.println("Say, "Hey!"");
    2. Serial.println(\"Say, "Hey!"\");
    3. Serial.println("Say, \"Hey!\"");
    4. Serial.println("Say, \"Hey!"\");

^ top

Joining Strings (Concatenation)

  • We can join strings together in a variety of ways
  • The join operation is called concatenation
  • We join two strings together using the '+' operator
  • We can concatenate a String variable with:
    • Another String variable
    • A literal string in double quotes like "abc"
    • A literal char like 'a' or a char variable
    • An literal integer like 123 or an integer variable

Examples of Concatenation

  • We can join a String variable with another, like:
    String s1 = "Hello", s2 = "World!";
    String s3 = s1 + s2;
    Serial.println(s3);
    
  • The String s3 now has the contents of both s1 and s2
  • We can also mix String variables and literal strings:
    String s1 = "Hello", s2 = "World!";
    String s4 = s1 + ", " + s2;
    Serial.println(s4);
    
  • One or both strings surrounding the + must be a String variable
  • For instance, the following will NOT work:
    String greeting = "Hello" + " " + "World!"; // No!
    
  • However, this is not usually a problem because we can just make one long literal string:
    String greeting = "Hello World!";
    
  • In addition, we can concatenate strings and characters:
    char letter = 'A';
    String s5 = "BC";
    s5 = letter + s5 + 'D';
    Serial.println(s5);
    
  • Arduino C++ also lets us join a string with an integer, like:
    String s6 = s5 + 123;
    Serial.println(s6);
    
  • Notice that we can concatenate a string with a floating-point number
    String s7 = s5 + 123.4567; // 2 decimal places
    
  • To control the number of decimal places we use a String constructor function to convert the number to a String like:
    String s8 = s5 + String(123.4567, 3);
    Serial.println(s8);
    
  • The first constructor function argument is the floating-point number and the second is the number of decimal places
  • We will discuss constructor functions in more detail later in the course

Example Code Showing Concatenation of Strings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void setup() {
  Serial.begin(9600);
  String s1 = "Hello", s2 = "World!";
  String s3 = s1 + s2;
  Serial.println(s3);
  String s4 = s1 + ", " + s2;
  Serial.println(s4);
  //String greeting = "Hello" + " " + "World!"; // No!
  char letter = 'A';
  String s5 = "BC";
  s5 = letter + s5 + 'D';
  Serial.println(s5);
  String s6 = s5 + 123;
  Serial.println(s6);
  String s7 = s5 + 123.4567; // 2 decimal places
  Serial.println(s7);
  String s8 = s5 + String(123.4567, 3); // 3 DP
  Serial.println(s8);
}

void loop() {
}

Appending Strings

  • Notice that we can append a string to a String variable
  • For example, we can add one string to the end of another using +=:
    String s9 = "Hello";
    s9 += " World";
    Serial.println(s9);
    
  • Appending can be useful when building up strings containing text and numbers from various sources

Simplifying Printing with Concatenation

  • We can simplify the output of mixed combinations of strings and variables
  • As an example, assume we want to print the value of the following two variables
    int a = 10;
    double b = 2.34;
    
  • We want to add a label so we know which value belongs with a variable, like:
    a=10, b=2.34
    
  • Without concatenation, we would write four lines of code:
    Serial.print("a=");
    Serial.print(a);
    Serial.print(", b=");
    Serial.println(b);
    
  • With concatenation, we can shorten the output code:
    String es = "";
    Serial.println(es + "a=" + a + ", b=" + b);
    
  • We must start any concatenation sequence with a String variable that has an assigned value
  • For this example we started with an empty string es

Check Yourself

  1. The operator used to join two strings is ________.
  2. The value of s3 after the following code executes is ________.
    String s1 = "Hi ", s2 = "Mom!";
    String s3 = s1 + s2;
    
  3. The result of trying to compile and run the following code is ________.
    String s1 = "Hi", s2 = "Mom!";
    String s3 = s1 + " " + s2;
    
  4. The result of trying to compile and run the following code is ________.
    String s1 = "Hi " + " " + "Mom!";
    

^ top

String Functions

  • Strings are a special type of variable called objects, which we will study in more detail later in the course
  • An object is a data type that can have functions associated with it
  • These functions are called member functions and are called using dot notation
  • The syntax for calling a member function of a string object is:
    stringName.functionName(arguments)
    
  • Where:
    • stringName: the name of the string variable
    • functionName: the name of the member function
    • arguments: the input values, if any
  • Once we create a String variable, we call (invoke) its member functions

Some Commonly-Used String Functions

  • Arduino C/C++ supports many String functions (see documentation)
  • We cover a few commonly used String functions in this section
  • length(): Returns the number of characters in a string
    String greeting = "Hello, World!";
    String msg = "The number of characters is ";
    msg += greeting.length();
    Serial.println(msg);
    
  • substring(from, to): Returns a substring starting at index from and ending just before to
  • For example, we extract the first 4 letters of a string:
    String greeting = "Hello, World!\n";
    String sub = greeting.substring(0, 4);
    
  • Similarly, we extract characters 7 to 12, but not including 12:
    sub += greeting.substring(7, 12);
    
    H e l l o ,
    W o r l d ! \n
    0 1 2 3 4 5 6 7 8 9 10 11 12 13
  • When finished, we print the message we extracted with substring():
    Serial.println(sub);
    
  • trim(): Removes any leading and trailing whitespace.
    String padding = "  text  \n";
    Serial.println("For the string \"" + padding + "\"");
    String msg = "the number of characters is ";
    Serial.println("Before trim() " + msg + padding.length());
    padding.trim();
    Serial.println("After trim() " + msg + padding.length());
    
  • The trim() function is useful for removing line endings when reading strings from the serial port
    String inStr = Serial.readString();
    inStr.trim();
    Serial.println(inStr);
    

Example Code Calling String Member Functions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void setup() {
  Serial.begin(9600);
  Serial.println("Enter a string");
}

void loop() {
  if (Serial.available()) {
    // Demonstrate input
    String inStr = Serial.readString();
    Serial.println("For the string \"" + inStr + "\"");
    String msg = "the number of characters is ";
    Serial.println("Before trim() " + msg + inStr.length());
    inStr.trim();
    Serial.println("After trim() " + msg + inStr.length());
    // Demonstrate substring()
    String greeting = "Hello, World!";
    Serial.println("For the greeting: " + greeting);
    String sub = greeting.substring(0, 4);
    sub += greeting.substring(6, 12);
    Serial.println("The substring greeting is: " + sub);
  }
}

Check Yourself

  1. True or false: an object is a data type that can have functions associated with it.
  2. To call a function that is part of an object, between the object name and the function name we code a ________.
  3. The following code displays ________.
    String message = "Hi mom!";
    Serial.println(message.length());
    
    1. 2
    2. 6
    3. 7
    4. "Hi mom!"
  4. For the following string variable, the function call that extracts "mom" is ________.
    String message = "Hi mom!";
    
    1. message.substring(3, 6)
    2. message.substring(2, 6)
    3. message.substring(3, 5)
    4. message.substring(2, 5)

^ top

Comparing Characters and Strings

  • Character data can be evaluated using relational operators
  • Relational operators are useful for making alphabetic comparison between characters, like:
    if ('A' < 'B')
    
  • Since C++ stores characters as numbers using ASCII codes, the computer is actually comparing numbers
  • Remember that letters nearer to the start of the alphabet have lower numerical values than later letters
  • Thus a numerical comparison can decide the alphabetical order of characters

Example Program Comparing Characters

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void setup() {
  Serial.begin(9600);
  char chOne = 'A';
  char chTwo = 'B';
  String sp = "'"; // to start print statements
  if (chOne == chTwo) {
    Serial.println(sp + chOne + "' == '" + chTwo + "'");
  }
  if (chOne != chTwo) {
    Serial.println(sp + chOne + "' != '" + chTwo + "'");
  }
  if (chOne < chTwo) {
    Serial.println(sp + chOne + "' < '" + chTwo + "'");
  }
  if (chOne <= chTwo) {
    Serial.println(sp + chOne + "' <= '" + chTwo + "'");
  }
  if (chOne > chTwo) {
    Serial.println(sp + chOne + "' > '" + chTwo + "'");
  }
  if (chOne >= chTwo) {
    Serial.println(sp + chOne + "' >= '" + chTwo + "'");
  }
}

void loop() {
}

Comparing Strings

  • We can compare strings using relational operators as well
  • C++ compares two strings using lexicographical order (a.k.a. alphabetical order)
  • Lexicographical order means the comparison is based on the alphabetical order of component letters
  • For example, "car" is less than "cat":
    c a r
    c a t
  • Also, "car" is less than "card"
    c a r
    c a r d
  • We can test string comparisons in the following example program

Example Program Comparing Strings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void setup() {
  Serial.begin(9600);
  String strOne = "car";
  String strTwo = "cat";
  if (strOne == strTwo) {
    Serial.println(strOne + " == " + strTwo);
  }
  if (strOne != strTwo) {
    Serial.println(strOne + " != " + strTwo);
  }
  if (strOne < strTwo) {
    Serial.println(strOne + " < " + strTwo);
  }
  if (strOne <= strTwo) {
    Serial.println(strOne + " <= " + strTwo);
  }
  if (strOne > strTwo) {
    Serial.println(strOne + " >= " + strTwo);
  }
  if (strOne >= strTwo) {
    Serial.println(strOne + " >= " + strTwo);
  }
}

void loop() {
}

Check Yourself

  1. The result of evaluating the following relational expression is ________.
    'A' < 'B'
  2. The result of evaluating the following relational expression is ________.
    "A" < "B"
  3. Of the following pairs of strings, which comes first in lexicographic order for each of them?
    1. "Harry", "Potter"
    2. "Harry", "Hairy"
    3. "car", "C++"
    4. "car model", "carburetor"

More Information

^ top

Exercise 1: Initials (10m)

In this exercise we write an interactive program using strings that runs like this:

Enter your first name: Ed
Enter your last name: Parrish
Welcome "Ed Parrish"!
Your initials: EP
Enter your first name: (so you can start over)

Note that the underlined font shows what is typed by the user in the text field at the top of the window. As you work through the exercise, I suggest that you compile after each step so you know where an error is located if you make a mistake. Also, if you get stuck then ask a classmate or the instructor for help.

Parts

  • Arduino board
  • USB cable

Starter Code

// Must remember names across loop() calls
String firstName = "";
String lastName = "";

void setup() {
  Serial.begin(9600);
  Serial.println("Enter your first name:");
}


void loop() {
  if (Serial.available()) {
    // put your code here
  }
}

Specifications

  1. Start the Arduino IDE, copy the starter code above and paste it into the main IDE window.
  2. Save the project using the name initials (File > Save As...) to a convenient location like the Desktop or the Arduino projects folder.
  3. Compile the sketch to verify you copied the starter code correctly.

    When compiling is successful, you will see a message at the bottom of the source code window saying, "Done compiling."

  4. Where shown by the comment, add a statement to read a string from the serial port and save it in a String variable named inStr, like:
    String inStr = Serial.readString();
    
  5. Next, add an if-else statement to test if the firstName variable is empty, like:
    if (firstName == "") {
      // add code to store inStr in firstName
    } else {
      // add code to store inStr in lastName and make initials
    }
    
  6. Inside the if-clause, assign inStr to firstName and then add a second statement prompting the user to enter their last name.
  7. Inside the else-clause, assign inStr to lastName and then add a series of statements that extract the first letter of the first and last names using substring() like:
    String initials = firstName.substring(0, 1);
    initials += lastName.substring(0, 1);
    
  8. Next inside the else-clause, print the welcome message followed by printing the initials, like:
    String sp = "Welcome \"";
    Serial.println(sp + firstName + " " + lastName + "\"!");
    Serial.print("Your initials are: ");
    Serial.println(initials);
    
  9. After the above statements, assign an empty string to both firstName and lastName and then print a message to enter the first name.
  10. Compile and upload your code to verify it works correctly.

    You should now be able to see it work like the example shown at the start. If you have problems, ask a classmate or the instructor for help.

  11. Verify your code with the example shown below. Your code does not need to be the same but comparing helps understand other ways of coding.
  12. Save your initials.ino file to submit to Canvas with the next homework.

When finished, please help those around you.

Completed Program

Completed exercise code

^ top

Summary

  • A character is a letter, number or special symbol
  • We make character literals by enclosing a single character in single quotes
  • We declare character variables using char as the data type:
    char letter = 'A';
    
  • Each character is stored as a number, using its ASCII code
  • We can input and output char data to the Serial Monitor like:
    char letter = Serial.read(); // input
    Serial.println(letter); // output
    
  • We make string literals by enclosing characters in double quotes
  • We declare string variables using String as the data type:
    String s1 = "Hello Mom!";
  • To concatenate two strings, use the "+" operator:
    String s2 = s1 + " suffix";
  • Type String can be input and output with the Serial Monitor
  • We use functions of the String object for some operations
  • We looked at the member functions:
    • length(): Returns the number of characters in a string
      string s = "Hello";
      Serial.println(s.length());
      
    • substring(from, to): Returns a substring starting at index from and ending just before to
    • String greeting = "Hello, World!\n";
      String sub = greeting.substring(0, 4);
      
    • trim(): Removes any leading and trailing whitespace, which is useful for removing line endings when reading strings from the serial port
      String inStr = Serial.readString();
      inStr.trim();
      Serial.println(inStr);
      
  • We can use these relational operators with characters and strings
  • Relational operators are useful for making alphabetic comparisons

^ top

Midterm Preparation

Learner Outcomes

At the end of the lesson the student will be able to:

  • Describe the ground rules for the midterm exam
  • Start preparing for the midterm exam

^ top

About the Exam

Important Midterm Exam Information

Date: 10/07/15
Location: Regular classroom
Start time: During the regular class time

  • The exam covers material from the first five weeks
  • Exam question types include multiple choice and short programming problems
  • You will have about 45 minutes to complete the exam

Basic Principles

  • You must attend the exam or you will receive a score of zero (0)
    • Except by prior arrangement with the instructor
  • Canvas will be used to administer the test
  • The exam is closed books and closed notes
    • However, you may have one 3" x 5" card of handwritten notes for the exam
  • You may use a computer from the classroom, but only to take the exam in Canvas
  • You may have a sheet of blank scratch paper
  • You may NOT use the computer to compile or run programs
  • You may NOT use the computer to view documents on the Internet
  • You may NOT use a calculator or other electronic device
    • Thus, you may NOT use your own computer to take the exam
    • If you have a cell phone visible or in use during the exam, you will automatically fail
  • You may NOT communicate with anyone but the instructor during the exam

3"x5" Card Requirements

  • Put your name on your card
  • Maximum card or paper size is 3 inches by 5 inches
  • You may use both sides of the card
  • Notes must be handwritten and NOT photocopied
  • Notes cannot have any complete functions -- only code snippets
  • Any 3" x 5" cards violating these rules will be confiscated before the test
  • You must turn in your 3" x 5" card after the exam

^ top

Test Preparation Self Assessment

Follow this link and take two minutes to read and answer the questions. (2m)

Discussions Questions

  • How are these practices beneficial?
  • What are your successful strategies for exam preparation?
  • How much time do you dedicate to test preparation?

^ top

forked road
How to Study for the Exam

  • No one can ace a test without studying and understanding the material
  • To get an "A" you need to thoroughly prepare for the test well in advance
  • With the midterm approaching, you have a choice:
    • Study and do well, or
    • Not study and do less than your best
  • Victims are people who let their lives control them, like a pawn on a chessboard
  • Creators are people who controls their own life, like a person playing chess
  • You can take responsibility for studying and do well on a test
  • Or you can make excuses and do less than you are capable of on a test

Boosting Your Performance

Here are some steps you can take to improve your test results:

  1. Compile a list of topics you might be tested on.

    Look over your assignments, exercises, and lecture notes to determine what we covered. Write a list of topics from these sources.

  2. Make sure you understand all the topics on your list.

    Correct any mistakes you may have made in your assignments, exercises or quizzes.

  3. Identify the most probable exam topics for thorough study.

    To do well, you need deep understanding of the test topics. Gaining a deep understanding takes time. Often you can tell what is on a test simply by which topics the instructor spends the most time talking about.

  4. Create a list of test questions.

    Turn headings from the textbook and lecture notes into questions. Look at the section summaries in the lectures and read the Check Yourself questions.

  5. Study your questions over and over until you know them perfectly.

    Make flash cards (or use an app) with questions on one side and answers on the other. Carry the cards with you and review them when you have a few minutes available. Have other people ask you questions from your flash cards. Do practice problems to gain a an even deeper understanding of coding techniques.

  6. Prepare your 3"x5" card of test notes.

    Since the instructor allows a 3"x5" card, make use of it. For the topics you had the most trouble with, write down a short note or summary. If the pressure of the test causes you to forget something, you can refer to your card.

More Information

^ top

Exercise: Preparing Exam Questions (5m)

Specifications

  1. Review the following is a list of test topics, pick one and let the instructor know your choice.

    Remember that later topics usually help you prepare better than earlier topics.

  2. As a lab homework for the next class meeting, prepare a list of five (5) questions on your assigned topic.
  3. Follow the instructions after the list to prepare the questions.
  4. Post the questions in the Discussions area of Canvas titled "Midterm 1 Study Questions" as discussed in the Lab instructions for the next class meeting.

Test Topics

  1. Commputer and Programming Basics
    1. Comments (01B:3.1)
    2. Arduino Commands and Functions (01B:3.2-3)
    3. Compiling and Syntax Errors (01B:4.1-2)
    4. Arduino Compiler and C++ (02B:2.2-4)
    5. Computer Instructions and Organization (02B:2.1)
    6. Sequence (02B:2.5)
    7. Pair Programming Roles and Rules (02B:3.1-2)
  2. Variables and Assignment
    1. Computer Memory (03A:2.1-3)
    2. Data Types (03A:2.4)
    3. Declaring Variables (03A:2.5, 02B:2.6)
    4. Variable Assignment (03A:2.6, 02B:2.6)
    5. Compound Assignment Operators, including Increment/Decrement (04b:2.5)
  3. Arduino Serial I/O
    1. Arduino Serial I/O Setup (03A:3.1-2, 01B:4.3)
    2. Arduino Serial Output (03A:3.3, 01B:4.3)
    3. Arduino Serial Input (03A:3.3-4)
  4. Conditional Statements
    1. if Statements (03B:2.1, 02B:2.8)
    2. Relational (Comparison) Operators (03B:2.2, 02B:2.9)
    3. if-else Statements (03B:2.3)
    4. Nested if Statements (03B:2.4)
  5. Arduino Digital I/O
    1. Arduino Digital I/O Setup (03B:3.1-2)
    2. Arduino Digital Output (03B:3.3)
    3. Arduino Digital Input (03B:3.3-4)
    4. Arduino Digital Input Pull-up Resistors (03B:3.5)
  6. Electricity and Resistance
    1. Ohm's Law (04A:1.1)
    2. Schematic Symbols (04A:1.2)
    3. Reading Resistors (04A:1.3)
    4. Series and Parallel Circuits (04A:1.4)
    5. Voltage Dividers (04A:1.5)
  7. Arduino Analog I/O
    1. Analog Input (04A:2.1)
    2. Analog Output (04A:2.2)
    3. Temperature Sensors (05A:3.1)
  8. Numbers and Computations
    1. Numbers and Arithmetic (04B:2.1-3, 02B:2.6)
    2. Integer Division and Modulus (04B:2.4)
    3. Mathematical Functions (04B:2.5)
  9. Characters and Strings
    1. Type char (04B:3.1)
    2. Strings (04B:3.2)
    3. Joining Strings (Concatenation) (04B:3.4)
    4. String Functions (04B:3.5)
    5. Comparing Characters and Strings (04B:3.6)
  10. Function Definitions
    1. Function Definition Syntax (05A:2.1-2)
    2. Parameters (05A:2.3)
    3. Return Types (05A:2.5)
    4. Tracing Function Calls (05A:2.7)
  11. Variable Scope
    1. Variable and Parameter Scope (05A:2.4)
    2. Constants and Magic Numbers (05A:3.3)
    3. Static Variables (05A:3.4)
  12. for Loops
    1. for Loops and Counting (06A:2.1-2, 02B:2.10)
    2. Summing Numbers and Averaging (06A:3.1-2)
    3. Tracing Loops (06A:3.2-3)

^ top

Wrap Up and Reminders

  • For the next homework, see the schedule
  • When class is over, please shut down your computer.
  • Complete unfinished exercises from today before the next class meeting

^ top