Bird
0
0
Arduinoprogramming~10 mins

Soil moisture sensor in Arduino - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read the soil moisture sensor value.

Arduino
int sensorValue = analogRead([1]);
Drag options to blanks, or click blank then click option'
AA0
B13
CGND
D5V
Attempts:
3 left
💡 Hint
Common Mistakes
Using a digital pin number instead of an analog pin.
Trying to read from power or ground pins.
2fill in blank
medium

Complete the code to print the sensor value to the serial monitor.

Arduino
Serial.println([1]);
Drag options to blanks, or click blank then click option'
Amoisture
BsensorValue
Csensor
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that was not declared.
Printing a string instead of the variable.
3fill in blank
hard

Fix the error in the code to initialize serial communication at 9600 baud.

Arduino
Serial.begin([1]);
Drag options to blanks, or click blank then click option'
A9600
B115200
C4800
D19200
Attempts:
3 left
💡 Hint
Common Mistakes
Using a baud rate that does not match the serial monitor setting.
Using a very high baud rate without hardware support.
4fill in blank
hard

Fill both blanks to create a condition that checks if the soil is dry (sensor value less than 300).

Arduino
if ([1] [2] 300) {
  Serial.println("Soil is dry");
}
Drag options to blanks, or click blank then click option'
AsensorValue
B<
C>
DmoistureLevel
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name.
Using the greater than operator instead of less than.
5fill in blank
hard

Fill all three blanks to map the sensor value (0-1023) to a percentage (0-100) and print it.

Arduino
int moisturePercent = map([1], 0, [2], 0, [3]);
Serial.print("Moisture: ");
Serial.print(moisturePercent);
Serial.println("%");
Drag options to blanks, or click blank then click option'
AsensorValue
B1023
C100
DmoistureValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names.
Mixing up the input and output ranges.