Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!


Step 0. Using your web browser, go directly to https://makecode.microbit.org to land the MakeCode for micro:bit home page. You can bookmark this package to easily open this package for next project. In the My Projects section, click on the New Project

For more information about MakeCode, please go to our tutorial: What is MakeCode


Step 1. In the Toolbox, click on the Variables category and then click the Make a Variable button, and then In the New Variable name window, type “reading” as the variable name, then click on the Ok button

Step 2. Drag and drop a set number to 0 block inside the forever block, and choose reading from the drop-down menu.

Step 3. In the Toolbox, click on the Pins category under Advanced. Now, click and drag the analog read pin P0 block over and place it inside the placeholder of the set reading to 0 block. Then choose P0 from the drop-down menu if it has not already been selected

Step 4. Drag and drop a set reading to 0 block inside the forvever block just below the set reading to block , and choose new variable from the drop-down menu to create “number” as a new variable name.

Step 5. In the Toolbox, click on the Math category and Click and drag the square robot 0 block over and place it inside the placeholder of the set number to 0 block. Then choose integer ÷ from the drop-down menu

Step 6. Drag and drop a reading block from variable category over and place it inside the placeholder of the integer ÷ block , and change 0 to 50.

Step 7. In the Toolbox, click on the Basic category, click and drag the show number 0 block over and place it inside of the forever block. The  simulator area will show 0

Step 8. Drag and drop a number block from variable category over and place it inside the placeholder of the show number 0 block

Step 9. In the Toolbox, click on the Logic category. Then click and drag the if-then-else block over and place it inside the forever block just below the show number block.

Step 10. Click on the Logic category again. Under the Comparison section, click and drag one of the blocks over, and place it on the placeholder of the if-then-else block (by default, the placeholder has a true-false block). Then choose “>” from the dropdown list.

Step 11. Drag and drop a number block from variable category over and place it on the first placeholder of the Comparison block. Also, change the second placeholder of the Comparison block to 5

Step 12. Click on the Pins category and drag and drop the digital write pin P0 to 0 block over and place it inside the “then” section of the if-then-else block. Then choose P1 from the drop-down menu and change 0 to 1

Step 13. Right-click on the digital write pin P1 to 1 block and click Duplicate from the shortcut menu and you will get a duplicated block. change 0 to 1 and drag and drop the duplicated block inside the “else” section.

Step 14. Download this “.hex” file and send it to your MICROBIT disk.

Below is the full code we have done for you as reference:

Complete wiring and power up, You should see the brightness data on the LED matrix of micro:bit.
If the brightness value is greater than 5, the light will be lit, otherwise, the light will remain extinguished.

Learn More about parts

No. Picture Product Name Link
1 BBC micro:bit micro Mainboard https://osoyoo.store/products/bbc-micro-bit-micro-controller-with-motion-detection-compass-led-display-and-bluetooth?variant=31021023002735
2 OSOYOO Expansion board for Micro:bit https://osoyoo.store/products/pnp-board-for-micro-bit-stem-kitmodel-2018005900?variant=31698997444719
3 Green LED Module https://osoyoo.store/products/green-led-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31957968158831
4 Yellow LED Module https://osoyoo.store/products/yellow-led-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500
5 Red LED Module https://osoyoo.store/products/red-led-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31957964882031
6 White LED Module https://osoyoo.store/products/white-led-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31816681128047
7 Humi & Temp Module https://osoyoo.store/products/humi-temp-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31957977563247
8 Passive buzzer Module https://osoyoo.store/products/passive-buzzer-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500
9 Flame sensor Module https://osoyoo.store/products/flame-sensor-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500
10 Red Button Module https://osoyoo.store/products/red-button-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31958006693999
11 Yellow Button Module https://osoyoo.store/products/yellow-button-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31958014328943
12 Photoresitor Module https://osoyoo.store/products/photoresitor-module-for-arduino-microbit-osoyoo-stem-kitmodel-2019011500?variant=31958061154415
13 RGB Module https://osoyoo.store/products/rgb-module-for-osoyoo-stem-kit-for-micro-bit-arduino-raspberry-pi-model-2019011500?variant=31958069739631
14 IR Receiver Module https://osoyoo.store/products/ir-receiver-module-for-arduino-raspberry-pi-micro-bit-stem-model-2019011500?variant=31958077309039
15 Infrared Remote Controller https://osoyoo.store/products/infrared-remote-controller-for-arduino-raspberry-pi-microbit-stemmodel-2019011500?variant=31958087532655
16 Microphone Module https://osoyoo.store/products/microphone-module-for-arduino-raspberry-pi-micro-bit-stem-model-2019011500?variant=31958089597039
17 Potentiometer Module https://osoyoo.store/products/potentiometer-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31817102852207
18 Fan Motor module https://osoyoo.store/products/fan-motor-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31957989359727
19 Micro Servo motor https://osoyoo.store/products/micro-servo-sg90-blue-for-arduino-v2-0-robot-carmodel-lacc200610
20 Ultrasonic detector module https://osoyoo.store/products/ultrasonic-detector-module-for-arduino-raspberry-pi-micro-bit-stemmodel-2019011500?variant=31958286729327
21 1602 I2C LED Screen https://osoyoo.store/products/white-led-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011501?variant=31817047048303
22 1 Channel Relay Module https://osoyoo.store/products/1-channel-relay-module-for-osoyoo-stem-kit-for-micro-bit-model-2019011500?variant=31957950562415