Introduction: Micro:bit: Raining Alarm Module
Micro:bit is an educational product put forward by British Broadcasting Corporation (BBC), which aims to help young people to learn basic programming knowledge. BBC micro:bit has rich board carrier resources such as button, 5*5 LED dot matrix, gyro, Bluetooth module, etc.. It is portable with only half size of a credit card. Maybe it is for keeping board size small, all IO ports on it do not lead to pins like Arduino . Today we are going to show you a small case to connect all pins on micro:bits with a breakout board.
In the following case, we will use micro:bit( breakout board connected) to produce a raining alarm module.
Requirement： When micro:bit senses raining，it will alarm with light and sound.
Breakout Board ×1
LED Module ×1
Dupont Cable ×3
IO Connection: P0 connect to passive buzzer module; P1 connect to raining sensor module; P2 connect to LED module. Note:Here, “P” stands for Pin. You can refer to the following picture for IO connection：
Note: The bottom base of pins on micro:bit breakout board has 3 different colors. Black stand for GND, red for VCC, yellow for signal. These colors are completely relative to the color of dupont cable. You can connect cables according to the relative color.
Step 1: Programming:
After we completed cable connection, click this link: https://makecode.microbit.org/ to open programming interface. We are going to do programming with Block method.
Here we have to note that the output of raining sensor module is analog signal and its correspond value read out by micro:bit is 0-1023.(In this case, 0 for no rain, 1023 for pour rain. Bigger value stands for heavier rain) Now we set the threshold value as 200. If the value on P1 port tested beyond 200, then it is raining and we can see a sign of umbrella on LED screen of micro:bit. At the same time, buzzer will alarm with music. You can refer to the following picture (picture 4) for how to set threshold value.
As for the whole program, you can refer to the following picture：
After we download the code to micro:bits, it will start to run the program automatically. Now pour some water on the raining sensor module to analogue raining effect. Let’s do it and take a look!
Step 2: Download Hex File
You can download the HEX file for this case here:
Question： If we want to divide raining to several levels like small rain, middle rain and pour rain and show it with different light and sound, then how to program? Your further discussion is welcomed!
For more details, you can refer to our User Guide.
We have a be nice policy.
Please be positive and constructive.