Watering your plants
We are now going to utilize every component we created in the past sections. Putting everything together, we will be building a completely automated plant watering system.
To start off, we need to create a new folder named plant-watering-system
inside the Chapter04
folder. Inside the new folder, create a new main.go
file with an empty main()
function inside. The final project structure should now look like the following:
Now, inside the main
function, follow these steps:
- Initialize the
ADC
interface:machine.InitADC()
- Initialize a new
soilSensor
:soilSensor := soil.NewSoilSensor(18000, 34800, machine. ADC5, machine.D2) soilSensor.Configure()
- Initialize a new
waterLevelSensor
:waterLevelSensor := waterlevel.NewWaterLevel(7000, ...