← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 27 · 40 questions
TalentJR

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. 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. 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. 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. 4.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 324. What happens?
    (a) lamp OFF (b) lamp ON
  5. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 17.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 38 °C. What happens?
    (a) fan ON (b) fan OFF
  18. 18.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 59 %. What happens?
    (a) pump OFF (b) pump ON
  19. 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. 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. 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. 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. 23.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 26 %. What happens?
    (a) pump ON (b) pump OFF
  24. 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. 25.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 428. What happens?
    (a) lamp OFF (b) lamp ON
  26. 26.🤖 if (temperature > 28) { fan ON } else { fan OFF }
    The temperature sensor reads 28 °C. What happens?
    (a) fan ON (b) fan OFF
  27. 27.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 38 %. What happens?
    (a) pump OFF (b) pump ON
  28. 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. 29.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 23 °C. What happens?
    (a) fan ON (b) fan OFF
  30. 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. 31.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 626. What happens?
    (a) lamp OFF (b) lamp ON
  32. 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. 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. 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. 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. 36.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 209. What happens?
    (a) lamp OFF (b) lamp ON
  37. 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. 38.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 481. What happens?
    (a) lamp OFF (b) lamp ON
  39. 39.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 316. What happens?
    (a) lamp ON (b) lamp OFF
  40. 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

  1. porch lamp ON
  2. both A and B are true
  3. Warm
  4. lamp ON
  5. the else part
  6. porch lamp OFF
  7. Cool
  8. Cool
  9. porch lamp OFF
  10. Warm
  11. porch lamp OFF
  12. Hot
  13. porch lamp OFF
  14. Cool
  15. porch lamp ON
  16. red LED ON
  17. fan ON
  18. pump OFF
  19. porch lamp OFF
  20. Warm
  21. red LED ON
  22. Warm
  23. pump ON
  24. buzzer beeps
  25. lamp OFF
  26. fan OFF
  27. pump ON
  28. Warm
  29. fan OFF
  30. Cool
  31. lamp OFF
  32. buzzer beeps
  33. buzzer is silent
  34. porch lamp OFF
  35. Cool
  36. lamp ON
  37. green LED ON
  38. lamp OFF
  39. lamp OFF
  40. red LED ON

Free electronics lessons, practice and worksheets at talentjr.in/electronics-for-kids