In this lesson, students will combine external inputs and outputs to create a plant moisture control system. Students will combine knowledge gained from the control lessons to convert an analog value into a percentage value as well as programming LED outputs.
- Understand how a control system works.
- Learn how to convert an analog value into a percentage value using the ‘map’ function in MkakeCode.
Download the Code
Click the button below to download the MakeCode editor code for this lesson. The hex file is contained in a zip folder.
Kindly refer to our download the code page for instructions on how to upload your code onto the micro:bit. Please use instructions set A.
This code can also be uploaded into the MakeCode editor.
- MicroUSB Cable
- 1 x House Plant
- 2 x Connector Cables
- Connect the micro:bit to the Innovation board via the edge connector.
- Use the connector cables to connect the moisture sensor to the ADC1 connector on the Innovation board and the LED to ADC2.
- Connect the micro:bit to a computer via the microUSB cable.
- Go to the MakeCode website on your computer and open a new project.
Time to Code
What Will Happen
The micro:bit will continually monitor the moisture level of the soil that the moisture sensor is inserted into. If the moisture level drops below 50% the red LED will light up alerting that the plant needs to be watered.
Button A can be pressed at anytime to view the current moisture level of the soil.
Taking it Further
- Design a casing for the soil moisture sensor.
- Investigate how to turn this into a fully autonomous system using a water pump controlled by the micro:bit.
Keep in Touch
We would love to keep in touch with you and as a result aid you along your digital making journey.
Becoming a digital maker subscriber means you will receive exclusive offers and we will keep you up to date with new resources and kits, as well as upcoming events and workshops.
Let us know how your digital education journey is progressing. Send us pictures and videos of your awesome creations and use the hashtag below.