← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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