Example Code for micro:bit-MakeCode-Control LED with Buttons
Learning Target: light up the LED light(the connection is shown below) Program Effect: press down button A to turn the LED light on, press button B to turn it off.
Hardware Preparation
- Components: 4 jumper wires, one LED light.
- Pin P0 will be used in the project.
Software Preparation
- Makecode: Click to enter makecode online programming environment: https://makecode.microbit.org/
Wiring Diagram

Sample Code
- Screenshot of makecode graphical codes:

Result
Press down button A to turn the LED light on, press button B to turn it off.
Was this article helpful?
