Review and Practice

Self-Check

In this activity, you learned how to use the digital_write() method to blink two lights in various arrangements to each other.

  • Were you able to blink the two lights together? Alternately?
  • Were you also able to get the two lights to blink in a sequence?
  • Thinking back over the last several activities. Do you understand the difference between how to work with write_analog and write_digital?

Questions

  1. When using the write_digital() method, how do you change the length of time the light stays on?
  2. In what order do the statements execute?
     

Exercises

  1. Change the blink rate in the following statement to 1/10 th of a second: sleep(500).
  2. What two “write” methods can be used to turn LEDs on and off?.
  3. Which “write” method turns the LED on for part of a period, adjusting the brightness level?
  4. Which loop keeps the statements repeating indefinitely?
  5. How can you easily change the script from two lights blinking simultaneously to blinking alternately?
  6. In which situation(s) are pin().write_digital() statements for blinking LEDs paired ahead of a sleep() statement: alternating, sequential, or simultaneous?
     

Project

Create a script that holds the green LED on while the yellow LED turns on and off. Place the code for the green LED outside the while True() loop.