Did You Know: Simultaneous vs. Sequential
Up to this point, it looks like both lights change at the same instant. In reality, the P13 light turned on a tiny fraction of a second before the P14 light. That’s because the micro:bit executes statements in a script sequentially—one after another. Since pin13.write_digital() comes before pin14.write_digital() in the script examples, the P13 light changes first. The P14 light changes an instant AFTER the P13 light.
In the current script, the time between light changes for P13 and P14 is not visible to the human eye. You can make it visible by adding a sleep statement between the two write_digital() calls (along with other changes).
Your Turn: On/Off Sequentially
Sequential blinking takes a few more changes since the script has to turn one light on/off, and then turn the other light on/off afterwards. In this approach, the script turns the P13 light on and off first, then follows with the P14 light.
- Change the line 1 comment and the project name field to led_blink_2x_sequential.
- Enter the script shown below, then click Save.
- Click Send to micro:bit.
- Verify that the P13 light turns on and off, then the P14 light turns on and off.