← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 215 · 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 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 370 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  2. 2.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 300 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  3. 3.🤖 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
  4. 4.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 35 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  5. 5.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 28 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  6. 6.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 150 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  7. 7.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 10 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  8. 8.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 28 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  9. 9.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 32 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  10. 10.🤖 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 ON (b) porch lamp OFF
  11. 11.🤖 if (temperature > 32) { 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
  12. 12.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 21 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  13. 13.🤖 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 OFF (b) porch lamp ON
  14. 14.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 535. What happens?
    (a) lamp OFF (b) lamp ON
  15. 15.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 170 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  16. 16.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 50 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  17. 17.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 620 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  18. 18.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 29 %. What happens?
    (a) pump OFF (b) pump ON
  19. 19.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 170 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  20. 20.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 43 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  21. 21.🤖 “if (A AND B)” is true when … (a) only B is true (b) both are false (c) only A is true (d) both A and B are true
  22. 22.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 94. What happens?
    (a) green LED ON (b) red LED ON
  23. 23.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 100 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  24. 24.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 102. What happens?
    (a) lamp OFF (b) lamp ON
  25. 25.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 35 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  26. 26.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 420. What happens?
    (a) lamp OFF (b) lamp ON
  27. 27.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 295. What happens?
    (a) lamp ON (b) lamp OFF
  28. 28.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 210. What happens?
    (a) lamp OFF (b) lamp ON
  29. 29.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 45 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  30. 30.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 27 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  31. 31.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 88. What happens?
    (a) green LED ON (b) red LED ON
  32. 32.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 380 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  33. 33.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  34. 34.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 27 %. What happens?
    (a) pump ON (b) pump OFF
  35. 35.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 18 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  36. 36.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 620 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  37. 37.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 56. What happens?
    (a) red LED ON (b) green LED ON
  38. 38.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 400 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  39. 39.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 43 %. What happens?
    (a) pump ON (b) pump OFF
  40. 40.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 170 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON

Answer key

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

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