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.)- 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.
- 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.
- 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)
- 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.
- 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.
- 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).
- 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