Bird
0
0
Arduinoprogramming~20 mins

Soil moisture sensor in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Soil Moisture Sensor Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Reading soil moisture sensor value
What is the output on the serial monitor when this Arduino code runs with the sensor reading analog value 600?
Arduino
int sensorPin = A0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  int sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  delay(1000);
}
A600
B1023
C0
DAnalog read error
Attempts:
2 left
💡 Hint
The analogRead function returns a value between 0 and 1023 based on the sensor voltage.
🧠 Conceptual
intermediate
1:30remaining
Understanding soil moisture sensor output range
Which statement correctly describes the soil moisture sensor output when connected to Arduino analog pin?
AThe sensor outputs a fixed voltage regardless of moisture.
BThe sensor outputs an analog voltage that varies with moisture level.
CThe sensor outputs a digital HIGH or LOW signal only.
DThe sensor outputs a PWM signal to indicate moisture.
Attempts:
2 left
💡 Hint
Think about how analog sensors work with Arduino analog pins.
🔧 Debug
advanced
2:00remaining
Fixing incorrect sensor reading code
What error does this Arduino code produce when trying to read soil moisture sensor value? int sensorPin = A0 void setup() { Serial.begin(9600); } void loop() { int moisture = analogRead(sensorPin); Serial.println(moisture); delay(1000); }
Arduino
int sensorPin = A0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  int moisture = analogRead(sensorPin);
  Serial.println(moisture);
  delay(1000);
}
ASyntaxError: missing semicolon after variable declaration
BRuntimeError: analogRead failed
CNo output, code runs fine
DTypeError: sensorPin is not defined
Attempts:
2 left
💡 Hint
Check the line where sensorPin is declared.
Predict Output
advanced
2:00remaining
Calculating moisture percentage from sensor value
What is the output of this code if analogRead returns 512? int sensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(sensorPin); int moisturePercent = map(sensorValue, 0, 1023, 0, 100); Serial.println(moisturePercent); delay(1000); }
Arduino
int sensorPin = A0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  int sensorValue = analogRead(sensorPin);
  int moisturePercent = map(sensorValue, 0, 1023, 0, 100);
  Serial.println(moisturePercent);
  delay(1000);
}
A512
B0
C50
D100
Attempts:
2 left
💡 Hint
The map function converts a number from one range to another.
🧠 Conceptual
expert
2:30remaining
Choosing correct sensor pin and reading method
Which option correctly explains why soil moisture sensor must be connected to an analog pin and read with analogRead() on Arduino?
ABecause soil moisture sensor outputs a digital signal that analogRead() converts to analog value.
BBecause digital pins automatically convert analog signals to digital values.
CBecause analog pins can only read digital signals from sensors.
DBecause soil moisture sensor outputs an analog voltage that digital pins cannot read directly.
Attempts:
2 left
💡 Hint
Think about the difference between analog and digital pins on Arduino.