︎Back to Interactive & Experience Design

Fall 2021 ︎︎︎ SUNY Purchase ︎︎︎ (DES3090) Interactive & Experience Design

CPX Warm up #3



(you may need to refresh to see the code)


If statement introduction︎︎︎

If statement without Boolean︎︎︎

If statment with else︎︎︎
If statement with elif (with "and")︎︎︎
Nested if statements︎︎︎
If statements without buttons (and "or")︎︎︎

Exercises

(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 week/warmup #, and the exercise number so something like “SantiagoBenjamin__WU3__E01.py” would be something I might name my files, but you’re not obligated to use this exact syntax.)
  1. Make it such that button A makes all the pixels turn blue (0, 0, 255) when the button is pressed and then 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 and appear 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 - 10 turn red (they will be off if no button is pressed)
  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. 
  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 #4, but amend it such that the switch will control whether the green pixels are blue or green (ie if the switch is “off”/False half the pixels are green, and if the switch is “on”/True that half of the pixels are blue).
  7. Start with your answers from Warm-up #2 for Exercises #3 and #5. Make it such that the switch being “off” will show the sequence for Exercise #3 and the switch being “on” will show the sequence for Exercise #5.


︎Back to Interactive & Experience Design