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