Pre-class Assignment
Please read through and complete the participation exercises under the C++ for lab 1 (and more) section of the zyBook. You can skip any “Try” exercises that require you to download RIMS for windows. Also finish up lab 0 if you haven’t completed it.
Announcements
- Lab 0 should be complete; check in with me after class if you are having issues
- Lab 1 is out and will be due in two weeks
- Lab hours Wednesdays 1:15pm-4pm in Singer 246 (overflow Singer 247)
- Office hours: by appointment (email me if none of those times work)
- The goal of this is to be more flexible / have more times, but I'm also open to a regularly scheduled time! Feel free to come as a group.
Learning Objectives and Outcomes
In this lecture, you will...
- listen to a short lecture on lab 1 and the associated code
- work together with Prof. Delano on an in class exercise
- start sketching out what you’ll do for the
getNumber
function for lab 1
By the end of this lecture, you should be able to...
- complete the first half of lab 1 (Exercises 0 – 3)
- Note that unless you are very strong at programing you will likely not finish Exercise 3 by the end of the lab section; this is fine! I expect you to work on this outside of lab.
Lecture Content
- A couple people had questions about how the
main
loop in our program works
main
has to return int
for our code to compile, but if ever return from main
(by explicitly returning an integer or excluding a while(1)
at the end of main
), our code will fault!
- When you run code on an operating system,
main
returns when exiting a program. However, on a microcontroller, there’s nothing to exit to, so we get a fault.
- RIMS review
- Built into browser; great for practicing some basics like bitwise manipulation (which you’ll do for lecture 4)
- Also has a desktop app but Windows only (won’t be required for course but you can use it if you want)
- Lab 1 Overview
- More programming topics for lab 1
- Header and cpp files
- For more information about header and cpp files, see here
enum
s and struct
- For more information about
enum
s and struct
s, see here and here
- What is the
&
symbol for when we use pc.write
?
- For more information about pointers, see here
Coding Example: getNumber
Let’s say for example we want to get 3 digit numbers from the serial monitor, and we ignore any characters that aren’t digits.