Microbit_tutorial


Makecode and Microbit basics:
If you don’t have makecode and microbit basics, you can follow the link to learn the basics: Click Me

Wiring diagram


Img

The USB port of the Microbit must be connected to the usb port of the PC through a micro usb cable.

Create a new project


Open the link to create a new online project: https://makecode.microbit.org
Img

Load extension library


Img

Fill in the link to the right of the chain and search for:
https://github.com/Mosiwi/Mosiwi-basic-learning-kit-for-microbit
Img
Wait for the loading of the library. After the loading is successful, the following figure is shown:
Img

Block code parsing


▶ 1: Img
The module returns a value that is the numeric input value for P11. When the keyboard on the sheild is clicked, a low level is returned, indicating that the keyboard value on the sheild can be read.
Img
Usage:
Press any keyboard on the sheild, the microbit dot matrix displays 0, otherwise displays 1.
Img
Because the P11 is also mapped to the microbit Buttom B, the keyboard value of the sheild can also be read through the microbit Buttom B.
Img

▶ 2: Img
Read the keyboard values on the sheild.
Usage:
Press any key on the sheild, and the microbit dot matrix displays the key value.
Img
Key value: U = 16, D = 8, L = 4, R = 2, OK = 1

▶ 3: Img
Clear the display on the 4-digit nixtube of the sheild.

▶ 4: Img
4-digit nixie tube displays numeric values.
Floating-point number display range: 0.0 to 999.9
Integer range: 0 to 9999
Usage:
Img

▶ 5: Img
Let one of the 4-digit nixie tubes display the number.
Parameter 1: 0 to 3, the position of the nixie tube to be lit.
Parameter 2: 0 to 15 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F), characters to display.

Usage:
Img

▶ 6: Img
A display segment in a nixie tube.
Img

▶ 8: Img
Let one of the 4-digit nixie tubes display a segment.
Parameter 1: 0 to 3, the position of the nixie tube to be lit.
Parameter 2: Img

Usage:
Img
The 4th digit tube display 2 segments.

▶ 9: Img
Light an LED in the strip.
Parameter 1: 0 to 8, the position of the LED to be lit.
Parameter 2: Img(0: OFF, 1: ON)

Usage:
Img

▶ 10: Img
Controls the brightness of the RGB LED on the sheild.
Parameter 1: Red LED, green LED, blue LED.
Parameter 2: 0 to 1023, brightness.

▶ 11: Img
Initial temperature and hygrometer.

▶ 12: Img
Read the temperature and humidity values and verify that the values are correct. Execute this block at a frequency greater than or equal to 2 seconds.

▶ 13: Img
Get the temperature or humidity value.

Usage:
Img

▶ 14: Img
When the ultrasonic module is connected to the Sensor interface of the sheild, the measurement distance value of the ultrasonic module can be read. The unit is centimeter.
Img

Usage:
Img

▶ 15: Img
The value of the infrared receiver, microphone or sliding resistor on the sheild is read through the I2C protocol.

Usage:
Infrared receiver (NEC)
Img
Img
Img

Microphone
Img

Sliding resistor
Img

▶ 16: Img
When the fan module is connected to the fan port on the sheild, it is used to control the steering and speed of the fan module.
Img
Parameter 1: CW = clockwise rotation.
Parameter 2: CCW = counterclockwise rotation.

▶ 17: Img
Read the key value on the sheild, return 0 when the key is pressed, otherwise return 1. This key is connected to the P5 pin of the microbit.
Img

▶ 18: Img
Reads a byte of data from the memory of the sheild.
Parameter: 0 to 16, Address of the memory.

▶ 19: Img
Write a byte of data to the memory of the sheild.
Parameter 1: 0 to 16, Address of the memory.
Parameter 2: 0 to 255, Data to be stored in memory.

Usage:
Img
4 digit nixie tube display 255.

End!