Exercise 4 - Blink Pattern
Goals
- Work with the digitalio library
- Utilize digital outputs to control an LED
- Utilize loops to accomplish repetitive tasks
Preparation
- Connect your board to the computer and open the
code.py
ormain.py
file. Whichever one you have is fine but I'll be referring to it ascode.py
. Delete any pre-existing code from the board. See getting started for help with this step. - We'll be running code from a python file today
Concepts & Vocabulary
- for loop
- while loop
- setup
range()
New Programming Syntax
Background Info
For this one, we're going to create a blinking pattern. Using the for loop we covered in class, create a pattern of blinking lights that changes over time. For instance, you might have it turn on for 1 second, then 2 seconds, then 3 seconds, and so on.
Try It
All of the code you need for this comes from exercise 3 and from the for loops above. We'll go over it in class too.
Show me your code in action
Total of 5 points
- 5 points: You created a for loop to blink in a pattern utilizing the variable that controls the loop
- 4 points: You created a for loop to blink your LED, but didn't utilize the variable
- 3 points: You set up your LED but didn't blink it
- 0 points: You didn't get a meaningful amount of this code completed