A Savior for Plants
Project Objectives
Master programming for hardware in the MakeCode Arcade. Interact with screens programmed to show the effects of watering and not watering separately. The screen displays the value of the soil's moisture condition.
Detect soil moisture using a Soil Moisture Sensor and water automatically when the soil moisture falls below a certain value.
Watering is carried out using a water pump, which is switched on and off by a motor.
Required Materials
[FutureBoard Lite](FutureBoard Lite)
Water tank & pump
PH2.0 Connecting Wire
Building Block Components
Circuit Wiring
Structural Assembly
Project Code
Upon opening, an error message will be displayed (Microsoft emulator has not added new hardware information), choose to ignore.
Code Interpretation
Create new settings for the screen background and several character objects, and set their respective positions. You can customize the characters and their positions according to your preferences.
In the loop of the program, display the soil's moisture level and determine whether to turn the water pump on or off based on the moisture level.
A reading of 400 corresponds to the condition when the soil module is not yet inserted into the soil, indicating an extremely dry state.
A reading of 2000 corresponds to the condition when the soil module detects very moist soil, reflecting the feedback value.
Both of these values can be adjusted according to actual conditions.
When the soil moisture level is below 40%, initiate watering.
Additionally, for the convenience of debugging and testing the water pump, A and B buttons have been added to control the water pump for watering.
Implementation Effect
When the soil moisture level is at 22% (less than 40%), the water pump automatically turns on, and the star character on the screen displays a fountain effect.