Skip to main content

A Savior for Plants

kittenbot_arcade_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

Circuit Wiring

arcade_plants_wiring

Structural Assembly

arcade_plants_assembly

Project Code

waterplant

Upon opening, an error message will be displayed (Microsoft emulator has not added new hardware information), choose to ignore.

error

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.

kittenbot_arcade_plants_code

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.

kittenbot_arcade_plants_code2

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.

kittenbot_arcade_plants_code3.png

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.

kittenbot_arcade_watering_plants