* Linkup science exp lessons to summarys * Busted hint syntax * Bad homeurl macro * Unlink 'magnetism' lesson
4.3 KiB
Setup and procedure
Setup
- Plan and design the experiments.
- Plan and design data collection documents.
- Program the @boardname@s.
- Experiment with different data collection scenarios.
- Add enhancements to the program and project.
Background
This project will use 2 pins on the @boardname@ to measure the voltage between the 3V pin and the pin 0 as the current travels through the soil. Wires or alligator clips are used to connect to the @boardname@. In the soil nails or larger wires are used as probes in the soil. The nutrients along with the moisture in the soil will allow an electrical current to travel through the soil. The more moisture in the soil the greater the voltage that is measured. Wet soil should have a reading around 1000
on a scale of 0 - 1024. Dry soil will give a reading of around 250
.
The @boardname@ has a analog to digital converter (ADC). This allows the microbit to read the analog voltage that is sent from the battery power supply (3 volts) through the soil. When the value is received it is converted to a digital value between 0-1024. This can allow the programmer to write the program to make decisions based on the reading returned to the display.
Code
This project will use a @boardname@ to collect data using the voltage that can be passed through a soil sample.
on Start event code
- Open MakeCode.
- Change the name of the project from “Untitled” to "Soil Moisture Tester".
- Place the show string block in the on start block and put the title
"SOIL MOISTURE TESTER"
in the quotes. - Check the display in the Simulator.
on Button "A" pressed code
- From the
||input:Input||
toolbox add an||input:on button "A" pressed||
block to the code. - From the
||basic:Basic||
toolbox add a||basic:show number||
block. - From the
||pins:Pins||
toolbox add an||analog read pin P0||
block to the end of the the||basic:show number||
block. - This will allow the soil moisture to be tested when the A button is pressed.
- Check the display in the Simulator.
- Download the project and copy it to the MICROBIT drive.
// Soil Moisture Tester
basic.showString("SOIL MOISTURE TESTER")
// The analog read will return a value of the voltage
// between the 3v pin and the P0. Values will range
// from 0-1024.
input.onButtonPressed(Button.A, () => {
basic.showNumber(pins.analogReadPin(AnalogPin.P0))
})
Project Testing
- Connect the alligator clips or wires to pin 0 and 3V. Clip nails or heavy wires to the other ends of the clips to create the probes.
- Place the probes in the soil and press the A button and read the output on the LED screen.
- Test different soils and record the readings.
- Check to make sure it works on the @boardname@.
- Share the project by clicking the Share button at the top of the editor window.
- Report on the findings from the experiment.
~hint
This experiment is modified from the Soil Moisture project.
~
Data Collection
Collect data from several different types of soil and moisture amounts and record it on the Data Collection sheet. Make modifications to the experiment and code as needed. Create a report to share your findings from the experiment.
Extensions
Conditional Responses
A conditional statements that would return messages based on the reading received from the probes.
if (condition) then
display (“WET”)
else if (second condition)
display (“MOIST”)
else
Display (“DRY”)
Dry Soil Sound Warning
Add code that would sound an alarm (play music) if the soil dries out below a certain point. The microbit could be left in a pot of soil with plants. It could be programmed to only sample the moisture every hour or so and then play the alarm when it is dry. This would help conserve the battery on the microbit.
Adapted from "Soil Moisture Tester" by C Lyman |