← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 484 · 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 < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 350 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  3. 3.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  4. 4.🤖 if (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 17 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  5. 5.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 540 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  6. 6.🤖 “if (A AND B)” is true when … (a) only B is true (b) both A and B are true (c) both are false (d) only A is true
  7. 7.🤖 if (light < 400 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
  8. 8.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 70. What happens?
    (a) red LED ON (b) green LED ON
  9. 9.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 65. What happens?
    (a) red LED ON (b) green LED ON
  10. 10.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 13 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  11. 11.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 41 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  12. 12.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 28 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  13. 13.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 26 %. What happens?
    (a) pump ON (b) pump OFF
  14. 14.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 540 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  15. 15.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 419. What happens?
    (a) lamp OFF (b) lamp ON
  16. 16.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 80 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  17. 17.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 240 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  18. 18.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 45 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  19. 19.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 73. What happens?
    (a) green LED ON (b) red LED ON
  20. 20.🤖 if (light < 400) { lamp ON } else { lamp OFF }
    The light sensor reads 461. What happens?
    (a) lamp OFF (b) lamp ON
  21. 21.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  22. 22.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 56. What happens?
    (a) red LED ON (b) green LED ON
  23. 23.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 46 %. What happens?
    (a) pump OFF (b) pump ON
  24. 24.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 23 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  25. 25.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 5 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  26. 26.🤖 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 ON (b) porch lamp OFF
  27. 27.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 640 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  28. 28.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 450 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  29. 29.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 450 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  30. 30.🤖 if (light < 200 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
  31. 31.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 14 %. What happens?
    (a) pump ON (b) pump OFF
  32. 32.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 60 %. What happens?
    (a) pump ON (b) pump OFF
  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 (distance < 15) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 10 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  35. 35.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 24 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  36. 36.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 61. What happens?
    (a) green LED ON (b) red LED ON
  37. 37.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 88. What happens?
    (a) red LED ON (b) green LED ON
  38. 38.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 440 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  39. 39.🤖 if (light < 400 AND 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
  40. 40.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 36 °C. What happens?
    (a) fan ON (b) fan OFF

Answer key

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

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