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 (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 650 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
2.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 50 %. What happens? (a) pump ON (b) pump OFF - 3.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) the if part (b) the else part (c) neither part (d) both parts
-
4.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 240 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
5.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 8 cm. What happens? (a) buzzer beeps (b) buzzer is silent -
6.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 3 cm. What happens? (a) buzzer beeps (b) buzzer is silent - 7.🤖 “if (A AND B)” is true when … (a) only B is true (b) both A and B are true (c) only A is true (d) both are false
-
8.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 33 °C. What is shown? (a) Cool (b) Warm (c) Hot -
9.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 47. What happens? (a) red LED ON (b) green LED ON -
10.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 170 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
11.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 18 °C. What is shown? (a) Warm (b) Hot (c) Cool -
12.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 650 and motion is detected (true). What happens? (a) porch lamp OFF (b) porch lamp ON -
13.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
The temperature is 36 °C. What is shown? (a) Cool (b) Warm (c) Hot -
14.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 23 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
15.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 180 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
16.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
The temperature is 26 °C. What is shown? (a) Warm (b) Cool (c) Hot -
17.🤖 if (sound > 70) { red LED ON } else { green LED ON }
The sound sensor reads 61. What happens? (a) green LED ON (b) red LED ON -
18.🤖 if (sound > 60) { red LED ON } else { green LED ON }
The sound sensor reads 78. What happens? (a) green LED ON (b) red LED ON -
19.🤖 if (moisture < 40) { pump ON } else { pump OFF }
The soil moisture sensor reads 50 %. What happens? (a) pump ON (b) pump OFF -
20.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 220 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
21.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
The temperature is 43 °C. What is shown? (a) Hot (b) Cool (c) Warm -
22.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 150 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
23.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
The distance sensor reads 26 cm. What happens? (a) buzzer is silent (b) buzzer beeps -
24.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 441. What happens? (a) lamp OFF (b) lamp ON -
25.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 24 °C. What happens? (a) fan OFF (b) fan ON -
26.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 54 %. What happens? (a) pump ON (b) pump OFF -
27.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 29 °C. What is shown? (a) Cool (b) Hot (c) Warm -
28.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 600 and motion is not detected (false). What happens? (a) porch lamp ON (b) porch lamp OFF -
29.🤖 if (moisture < 50) { pump ON } else { pump OFF }
The soil moisture sensor reads 35 %. What happens? (a) pump OFF (b) pump ON -
30.🤖 if (light < 200) { lamp ON } else { lamp OFF }
The light sensor reads 157. What happens? (a) lamp OFF (b) lamp ON -
31.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
The temperature is 11 °C. What is shown? (a) Warm (b) Hot (c) Cool -
32.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 220 and motion is not detected (false). What happens? (a) porch lamp OFF (b) porch lamp ON -
33.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
The temperature is 28 °C. What is shown? (a) Warm (b) Cool (c) Hot -
34.🤖 if (moisture < 30) { pump ON } else { pump OFF }
The soil moisture sensor reads 14 %. What happens? (a) pump OFF (b) pump ON -
35.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 32 °C. What happens? (a) fan OFF (b) fan ON -
36.🤖 if (temperature > 25) { fan ON } else { fan OFF }
The temperature sensor reads 22 °C. What happens? (a) fan ON (b) fan OFF -
37.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
The temperature is 21 °C. What is shown? (a) Warm (b) Cool (c) Hot -
38.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
The light reading is 150 and motion is detected (true). What happens? (a) porch lamp ON (b) porch lamp OFF -
39.🤖 if (light < 500) { lamp ON } else { lamp OFF }
The light sensor reads 368. What happens? (a) lamp OFF (b) lamp ON -
40.🤖 if (temperature > 30) { fan ON } else { fan OFF }
The temperature sensor reads 35 °C. What happens? (a) fan ON (b) fan OFF
Answer key
- porch lamp OFF
- pump OFF
- the else part
- porch lamp OFF
- buzzer beeps
- buzzer beeps
- both A and B are true
- Hot
- green LED ON
- porch lamp OFF
- Cool
- porch lamp ON
- Warm
- buzzer is silent
- porch lamp OFF
- Warm
- green LED ON
- red LED ON
- pump OFF
- porch lamp ON
- Hot
- porch lamp ON
- buzzer is silent
- lamp ON
- fan OFF
- pump OFF
- Warm
- porch lamp OFF
- pump ON
- lamp ON
- Cool
- porch lamp OFF
- Warm
- pump ON
- fan ON
- fan OFF
- Cool
- porch lamp ON
- lamp ON
- fan ON
Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids