← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 715 · 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 < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 600 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  2. 2.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 23 %. What happens?
    (a) pump ON (b) pump OFF
  3. 3.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 499. What happens?
    (a) lamp ON (b) lamp OFF
  4. 4.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 650 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  5. 5.🤖 In “if (temp > 30)”, what runs when temp is exactly 30? (a) both parts (b) neither part (c) the else part (d) the if part
  6. 6.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 41 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  7. 7.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 570 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  8. 8.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 492. What happens?
    (a) lamp ON (b) lamp OFF
  9. 9.🤖 if (light < 400 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 ON (b) porch lamp OFF
  10. 10.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 73. What happens?
    (a) red LED ON (b) green LED ON
  11. 11.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 460 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  12. 12.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 43 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  13. 13.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 8 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  14. 14.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 570 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  15. 15.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 14 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  16. 16.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 282. What happens?
    (a) lamp OFF (b) lamp ON
  17. 17.🤖 “if (A AND B)” is true when … (a) only A is true (b) both are false (c) both A and B are true (d) only B is true
  18. 18.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 19 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  19. 19.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 340 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  20. 20.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 140 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  21. 21.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  22. 22.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 18 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  23. 23.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 18 %. What happens?
    (a) pump ON (b) pump OFF
  24. 24.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  25. 25.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 99. What happens?
    (a) lamp ON (b) lamp OFF
  26. 26.🤖 if (light < 300 OR 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 (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 370 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  28. 28.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 130 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  29. 29.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 125. What happens?
    (a) lamp ON (b) lamp OFF
  30. 30.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 430 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  31. 31.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 27 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  32. 32.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 219. What happens?
    (a) lamp ON (b) lamp OFF
  33. 33.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 52 %. What happens?
    (a) pump ON (b) pump OFF
  34. 34.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 500 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  35. 35.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 42 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  36. 36.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 29 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  37. 37.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 27 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  38. 38.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 220 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  39. 39.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 100 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  40. 40.🤖 if (light < 200 OR 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

Answer key

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

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