Pre-Lecture Prep and Pre-Quiz

Please read the short writeup about while loops and complete the pre-quiz before class (links on Moodle).

Announcements

Learning Objectives and Outcomes

In this lecture, you will...

By the end of this lecture, you should be able to...

While Loops

The default flow of an Arduino program is controlled using setup() and loop(), with setup() running once and loop() repeating indefinitely:

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/8cca8045-ade0-4c59-a11b-b71cb5a7a9cb/setupLoop.png

The main technique we have discussed to change the program flow inside is if statements (and their variants such as switch-case statements). These statements run a single time; there is no additional loop component to them. But suppose we would like to wait for an input to occur and pause the code, or turn on a sequence of neopixels on programmatically. This is where a new type of technique comes into play: while loops.