← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 229 · 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.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) both parts (b) the else part (c) neither part (d) the if part
  2. 2.🤖 “if (A AND B)” is true when … (a) both are false (b) both A and B are true (c) only A is true (d) only B is true
  3. 3.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 190 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  4. 4.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 537. What happens?
    (a) lamp ON (b) lamp OFF
  5. 5.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 276. What happens?
    (a) lamp ON (b) lamp OFF
  6. 6.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 339. What happens?
    (a) lamp OFF (b) lamp ON
  7. 7.🤖 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
  8. 8.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 580 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  9. 9.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 420 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  10. 10.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  11. 11.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 410 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  12. 12.🤖 if (light < 300 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
  13. 13.🤖 if (light < 400 OR 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
  14. 14.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 420 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  15. 15.🤖 if (light < 400 OR 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
  16. 16.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 41 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  17. 17.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 17 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  18. 18.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 23 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  19. 19.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 41 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  20. 20.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 16 %. What happens?
    (a) pump OFF (b) pump ON
  21. 21.🤖 if (light < 400 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
  22. 22.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 21 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  23. 23.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 538. What happens?
    (a) lamp OFF (b) lamp ON
  24. 24.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  25. 25.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 520 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  26. 26.🤖 if (light < 400 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 OFF (b) porch lamp ON
  27. 27.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 35 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  28. 28.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 530 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  29. 29.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 32 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  30. 30.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 309. What happens?
    (a) lamp OFF (b) lamp ON
  31. 31.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 39 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  32. 32.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 447. What happens?
    (a) lamp OFF (b) lamp ON
  33. 33.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 36 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  34. 34.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 510 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  35. 35.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  36. 36.🤖 if (light < 400 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
  37. 37.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  38. 38.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 66. What happens?
    (a) red LED ON (b) green LED ON
  39. 39.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 580 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  40. 40.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 24 %. What happens?
    (a) pump OFF (b) pump ON

Answer key

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

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