Our Goal



What is a simple alarm box.

Pre Build Overview

Practical Operation

Set and stick components as below:

Hardware Connect

Connect the crash sensor to P1 port of the expansion board; Connect the rainbow LED to P2 port of the expansion board; Connect the soil moisture sensor to P1 of the expansion board.




Step 1

Note: If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Projects file menu.

Step 2

First of all, initialize the OLED using blocks in the OLED section as shown in the picture. Snap the “set to Neopixel” from the Neopixel, set rainbow led of the P2 port to singel light in RGB mode. And snap the “setup crash sensor” from the Smarthome Libraries and set it to P1 port to detect the press of the crash sensor.

Step 3

Since there are only two conditions, we need only one ‘else-if’ statement. When the Crash Sensor is pressed, the green Octopus LED will light up. Or else, if no force is applied to the Crash Sensor, the red LED will blink continuously.


If you don’t want to type these code by yourself, you can directly download the whole program from the link below:

Program link:https://makecode.microbit.org/_5UjPKXTgvJEb

You also could directly download program by visiting website as below:




More Information