Electronics Worksheet: If Else with Sensors
Remember (Test, then choose): Put the reading into the condition: true → the if part, false → the else part. > means strictly more and < strictly less; an equal reading makes them false. AND: both true. OR: at least one true. In a chain, the first true condition wins.
NameDateTime takenScore ___ / 40
-
1.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 35 %. What happens? (a) pump OFF (b) pump ON - 2.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) both parts (b) neither part (c) the else part (d) the if part
-
3.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 120 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
4.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 30 %. What happens? (a) pump OFF (b) pump ON -
5.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 480 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
6.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 39 °C. What is shown? (a) Hot (b) Cool (c) Warm -
7.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 64. What happens? (a) green LED ON (b) red LED ON -
8.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 26 cm. What happens? (a) buzzer beeps (b) buzzer is silent - 9.🤖 “if (A AND B)” is true when … (a) only B is true (b) both A and B are true (c) both are false (d) only A is true
-
10.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 50 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
11.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 60 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
12.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 8 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
13.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 410 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
14.🤖 if (temperature > 28) { fan ON } else { fan OFF }
The temperature sensor reads 21 °C. What happens? (a) fan ON (b) fan OFF -
15.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 25 °C. What is shown? (a) Hot (b) Warm (c) Cool -
16.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 490 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
17.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 442. What happens? (a) lamp ON (b) lamp OFF -
18.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
19.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 130 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
20.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 29 %. What happens? (a) pump OFF (b) pump ON -
21.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Cool (b) Warm (c) Hot -
22.🤖 if (temperature > 32) { fan ON } else { fan OFF }
The temperature sensor reads 36 °C. What happens? (a) fan ON (b) fan OFF -
23.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 24 °C. What is shown? (a) Cool (b) Warm (c) Hot -
24.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 30 °C. What is shown? (a) Warm (b) Cool (c) Hot -
25.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 237. What happens? (a) lamp OFF (b) lamp ON -
26.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 37 °C. What is shown? (a) Hot (b) Warm (c) Cool -
27.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 590 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
28.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 28 %. What happens? (a) pump ON (b) pump OFF -
29.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 35 °C. What is shown? (a) Hot (b) Warm (c) Cool -
30.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 234. What happens? (a) lamp OFF (b) lamp ON -
31.🤖 if (sound > 80) { red LED ON } else { green LED ON }
The sound sensor reads 98. What happens? (a) green LED ON (b) red LED ON -
32.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 49. What happens? (a) red LED ON (b) green LED ON -
33.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 120 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
34.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 270 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
35.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 50 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
36.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
The temperature is 44 °C. What is shown? (a) Cool (b) Warm (c) Hot -
37.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 37 °C. What is shown? (a) Warm (b) Cool (c) Hot -
38.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 42 %. What happens? (a) pump OFF (b) pump ON -
39.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 26 °C. What happens? (a) fan OFF (b) fan ON -
40.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 27 °C. What is shown? (a) Cool (b) Hot (c) Warm
Answer key
- pump ON
- the else part
- porch lamp ON
- pump ON
- porch lamp OFF
- Hot
- green LED ON
- buzzer beeps
- both A and B are true
- porch lamp ON
- porch lamp OFF
- buzzer beeps
- porch lamp OFF
- fan OFF
- Warm
- porch lamp OFF
- lamp ON
- porch lamp ON
- porch lamp OFF
- pump ON
- Cool
- fan ON
- Warm
- Warm
- lamp OFF
- Hot
- porch lamp OFF
- pump ON
- Warm
- lamp OFF
- red LED ON
- green LED ON
- porch lamp OFF
- porch lamp ON
- porch lamp OFF
- Hot
- Hot
- pump OFF
- fan ON
- Warm
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids