Review and Practice

Self-check

  • In this activity, you:
    • Built and tested a second pushbutton circuit.
    • Incorporated it into a light control project.
    • Changed the light control project’s features.
  • Does your second pushbutton operate correctly?
  • Were you able to create multiple pushbutton projects incorporating multiple LEDs?
  • Do you understand how various loop commands can be used to control the functioning of the pushbuttons and LEDs?

Questions

  1. What component(s) on your breadboard are used for input and can be used as control devices?
  2. What does it mean for an if statement to be nested?

Exercises

  1. In basic terms, what happens when statements inside while True and if statements aren’t indented properly?
  2. How are list and index used to move through items in a list?
  3. How are pushbuttons used to manipulate other components?
     

Projects

  1. Modify the Your Turn script so that there are no LEDs lit unless a button is being pressed.
  2. Modify the Your Turn script so that the lights stay on for increasingly longer (or shorter) lengths of time depending on which pushbutton is held down. Maintain the LED color change as it is.
  3. For this project combine what you know about the zip function (from the LED Lights tutorial), lists, and pushbuttons to create a script that cycles through each LED in increasingly longer time spans before cycling back through the color sequence each time the pushbutton at P9 is pressed (not held down).