Review and Practice

Self-check

  • In this activity, you:
    • built an LED circuit and used a script to turn the LED off and on, adjusting the timing to create different patterns.
    • calculated the period, frequency, and duty cycle.
  • Did you successfully build your LED circuit?
  • Can you adjust the rate at which the LED blinks and create different patterns?
  • Do you understand period, frequency, and duty cycle and can you calculate each?

Questions

  1. What are LEDs used for in products, and what are examples where they are used?
  2. How is period defined?
  3. How is frequency defined?
  4. How is duty cycle defined?
  5. What ways are you able to modify the blink of a light?

Exercises

  1. How would you modify a light on/off loop to change it from blinking every ½ second to blinking every ¼ second?
  2. How do you vary the script so that the time the light is on is longer than the time off?
  3. What sleep values would make the light appear to constantly be on but still be blinking?
  4. What part of the write_digital() statement signals that the light will turn off?
  5. How can the for...in range() loop be used with a light?
  6. If the period length is 1 s and the LED is on for .25 s during the period, how long is the LED off?
  7. If the period is .75 s, what is the frequency?
  8. What is the duty cycle for an LED that stays on for 500 ms and off for 500 ms?
  9. If the duty cycle is 30% and the LED stays on for 300 ms, how long is the period?

Projects

  1. Try adjusting the Try This - Blink Timing script to mimic a typical counting crosswalk signal. What considerations are there?
  2. Some warning lights blink faster as they ‘run out of time,’ for example the classic movie bomb countdown timer. Write a script to mimic this.