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
- When using the write_digital() method, how do you change the length of time the light stays on?
- In what order do the statements execute?
Exercises
- Change the blink rate in the following statement to 1/10 th of a second: sleep(500).
- What two “write” methods can be used to turn LEDs on and off?.
- Which “write” method turns the LED on for part of a period, adjusting the brightness level?
- Which loop keeps the statements repeating indefinitely?
- How can you easily change the script from two lights blinking simultaneously to blinking alternately?
- 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.