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