Exercise 5 - Addressable RGB LEDs
Goals
- Work with the dotstar or neopixel library
- Work with more complex data types
- Comment out code to control which sections of code run
- Utilize loops to accomplish repetitive tasks
Preparation
- Connect your board to the computer and open the
main.py
file. Please make sure you're opening the one on your board, not a copy saved on your computer! See getting started for help with this step. - We'll be running code from a python file today
- To make sure you're working with the correct file, add a print function to your code (for instance,
print("It's time to play with LEDs")
) and make sure it runs - After you've done that, please copy and paste the sample code below to your
main.py
file
Concepts & Vocabulary
- tuple
- addressable RGB LED
- commenting out code
Starting Code
- You're going to need to comment out one of the two pairs of lines here, depending on which board you have
- You can set this to any value from 0 to 1. Try other values!
- This loop will run forever. Could you change it to run 5 times? Try it!
- This sets the first LED in the chain to red. Could you make it orange instead?
Try It
Modify the code above to change the pattern of colors it shows
Show me your code in action
Today, I'm just checking for completion. You'll have another assignment to show me more advanced usage