Programming and note
The touch sensor can detect the human touch by sensing changes in
capacitance. When it detects a touch, it outputs a HIGH logic level signal.
Based on the touch IC TTP223-B, this module can detect human finger in
0~3mm, that is, you can place this sensor on a non-metallic surface such as
the glass or paper, with a thickness of less than 3MM, this would be useful for
applications that waterproof is needed, or you want to keep the buttons
secret.
Show Icon:
We can use this
show icon
block
to draw icons on the Micro:bit’s matrix LEDs.
Many icons have already been created in this
block, so we just need to select the icon to be
drawn.
If/else if/else statement:
If/else if/else is a
logical structure that is very similar to if/else.
Actually, it is derived from the if / else
structure. It can resolve judgments when there
are more than two cases. If the logical
statement that is attached to if(analog read
from P0 is less than 50) is true, then it will
execute the code blocks inside of the
if
.
If the
logical statement that is attached to
else if
(analog read from P0 is more than 500) is true,
then it will execute the code blocks inside of
the
else if
. Else(analog read from P0 is larger
than 50 and less than 500), it will execute the
else
blocks.
Download the program to micro:bit to see what happens.
When the soil moisture sensor is inserted into the dry soil, the buzzer will
beep and the X icon will be displayed on the micro: bit matrix LED; when it is
inserted into the Water-filled soil, the LED will light up and a sad icon will be
displayed on the micro: bit's matrix LED; when it is inserted into the moist
soil, the LED will not light up, the buzzer will not beep, and a happy icon will
be displayed on the micro: bit's matrix LED.
Result
Can we make an automatic watering system for plants after detecting low soil moisture?
And how to make it?
20