Example Code for MindPlus-micro:bit-LED Control
Control the LED light using the Photo Interrupter. When the Photo Interrupter is blocked, the LED light will turn on; otherwise, the LED light will turn off.
Hardware Preparation
- 1 x micro:bit
- 1 x IO Extender for micro:bit
- 1 x photo interrupter
- 1 x LED Light
- 1 x Digital Connection Cable
Software Preparation
Wiring Diagram
Connect the Photo Interrupter to the P1 pin on the IO Extender for micro:bit, and connect the LED light to the P2 pin.

Sample Code

Result
After the program is successfully downloaded, the LED light will turn on when the Photo Interrupter is blocked; otherwise, the LED light will turn off.

Was this article helpful?
