(Exercise) Code Homework no.03

Intstructions

Make sure that you upload each code example to the respective area in the spreadsheet. Create a separate .py for each exercise. Please make the files are named clearly, they need at least, your name, the #, and the exercise number so something like “SantiagoBenjamin__WU01__E01.py” would be something I might name my files, but you’re not obligated to use this exact syntax.
Make sure that each of your code examples has comments!

Questions

  1. Make it such that button A makes all the neopixels turn blue (0,0,255) when the button is pressed and turn off when the button is released

  2. Make it such that button B will make all the pixels turn green (0, 255, 0) when the button is released/when initially turned on and off when the button is pressed

  3. Make it such that button A will make neopixels 0 - 4 turn blue, and button B will make neopixels 5 - 9 turn red. They should all be off if neither button is depressed.

  4. Make code such that, pressing button A will make all the neopixels blue, pressing button B will make all the neopixels red, and pressing both A and B will make all the neopixels pink (255,0,255). (Pressing neither will turn both buttons off)

  5. Make it such that every other neopixel will be either green or red. That is to say neopixel 0 is green, neopixel 1 is red, etc.

  6. Start with your example from exercise #5 (every other neopixel is green or red), but amend it such that the toggle switch will swith the green and red neopixels (0 is red, 1 is green, etc)

  7. Start with the following:

  • (sequence 1) Code that makes all neopixels “glow” green, and then “glow” red
  • (sequence 2) Code that makes each neopixel “glow” white in sequence

Then, use the switch to control whether sequence 1 or sequence 2 is visible.

  1. (Challenge/extra credit!) Redo the question number 5 to use the modulo operator (if you did not already, and in your comments explain why it works)