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