Solutions

Questions

  1. Answer:  Use the sleep() function.
  2. Answer: Sequentially within loops.

Exercises

  1. Answer:  change sleep(500) to sleep(100)
  2. Answer:  write_analog() and write_digital()
  3. Answer:  write_analog()
  4. Answer: while True
  5. Answer:  Change the values in the pair of write_digital() statements for the lights from 0,0 and 1,1 to 1,0 and 0,1
  6. Answer:  alternating and simultaneous
     

Project

Solution:

from microbit import*

pin13.write_digital(1)

while True:
    
    pin14.write_digital(1)
    sleep(500)
    pin14.write_digital(0)
    sleep(500)