for(int i = 3; i >= 0; i--) {
/* get single bits of the analog value */
bits[i] = analog_value % 10;
analog_value = analog_value / 10;
tm1637.display(i, bits[i]); /* display by 4-digital display */
}
delay(200);
}
RESULT
If a plant needs water, the red LED of the LaunchPad will be turned on. Note that depending on
the resolution of your LaunchPad kit’s ADC (analog-to-digital converter), your range may vary.
For an 8-bit ADC, a number from 0-255 will show. For a 10-bit ADC, a number from 0-1023 will
show. For a 12-bit ADC, a number from 0-4095 will be displayed on 4-Digit Display. Carefully
dip the moisture sensor into water & watch the values change on the 4-Digit Display. Also watch
the red LED turn off and on.
TIPS
Moisture-Sensor is an analog sensor, by which you can measure the water amount that your
plant needs. Try to buzz a buzzer when your plant needs watering.