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

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?

TOP