Example - 09 : Taking Care of Your Plants (Moisture Sensor)
WHAT ARE WE DOING HERE?
The following sketch demonstrates a simple application of sensing the moisture in soil. With this,
you can know whether your plant needs water or not by observing the results from the output of
the sensor.
THE CIRCUIT
● Grove-Moisture Sensor x1
● Grove-4-Digit Display x1
● Grove cable x2
● Grove-Base BoosterPack x1
● LaunchPad Development Kit
Connections:
Plug the Grove-Moisture Sensor module into
Analog Grove connector J6 on the
BoosterPack. This will link the SIG pin of the
moisture sensor to pin 24 of the LaunchPad.
Plug the Grove-4-Digit Display into Digital
Grove connector J14. This will link the 2 SIG
pins (CLK & DIO) of the 4 digit module to pins
38 & 39 of the LaunchPad.
CODE
This example is available here:
File > Sketchbook > LaunchPad_Grove_Kit> moisture_sensor
Note that you may need to adjust the THRESHOLD_VALUE for your desired sensitivity.
/*
Moisture-Sensor
The following sketch demonstrates a simple application of sensing
the moisture of the soil. You can know whether a plant needs water
or not by observing the results that the sensor outputs.
The circuit:
* Moisture-Sensor attached to pin 24 (J6 plug on Grove Base BoosterPack)
* one side pin (either one) to ground
* the other side pin to +VCC
* LED anode (long leg) attached to RED_LED
* LED cathode (short leg) attached to ground
* Note:
批注 [18]: Update file path and add header files and tell
them to reset the LaunchPad if display is off.