← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 294 · 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) the if part (b) both parts (c) the else part (d) neither part
  2. 2.🤖 if (light < 400 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
  3. 3.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 24 °C. What happens?
    (a) fan ON (b) fan OFF
  4. 4.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 311. What happens?
    (a) lamp OFF (b) lamp ON
  5. 5.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 70 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  6. 6.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 260 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  7. 7.🤖 “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
  8. 8.🤖 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 ON (b) porch lamp OFF
  9. 9.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 390 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  10. 10.🤖 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 ON (b) porch lamp OFF
  11. 11.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 17 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  12. 12.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 361. What happens?
    (a) lamp OFF (b) lamp ON
  13. 13.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 290. What happens?
    (a) lamp ON (b) lamp OFF
  14. 14.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 66. What happens?
    (a) red LED ON (b) green LED ON
  15. 15.🤖 if (light < 300 OR 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
  16. 16.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 77. What happens?
    (a) red LED ON (b) green LED ON
  17. 17.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  18. 18.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 19 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  19. 19.🤖 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
  20. 20.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 32 %. What happens?
    (a) pump ON (b) pump OFF
  21. 21.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 180 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  22. 22.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 21) { show “Warm” } else { show “Cool” }
    The temperature is 22 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  23. 23.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 35 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  24. 24.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 58. What happens?
    (a) green LED ON (b) red LED ON
  25. 25.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 180 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  26. 26.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 80 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  27. 27.🤖 if (light < 300 AND 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
  28. 28.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  29. 29.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 200. What happens?
    (a) lamp ON (b) lamp OFF
  30. 30.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  31. 31.🤖 if (light < 400 OR 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
  32. 32.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 490 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 > 23) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  34. 34.🤖 if (temperature > 28) { fan ON } else { fan OFF }
    The temperature sensor reads 25 °C. What happens?
    (a) fan OFF (b) fan ON
  35. 35.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 73. What happens?
    (a) green LED ON (b) red LED ON
  36. 36.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 160 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  37. 37.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 17 °C. What happens?
    (a) fan ON (b) fan OFF
  38. 38.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 60 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  39. 39.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 81. What happens?
    (a) red LED ON (b) green LED ON
  40. 40.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 630 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON

Answer key

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

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