← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 199 · 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 590 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  2. 2.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 430 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  3. 3.🤖 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
  4. 4.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 60 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  5. 5.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 3 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  6. 6.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 42 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  7. 7.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 37 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  8. 8.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 34 %. What happens?
    (a) pump OFF (b) pump ON
  9. 9.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 24 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  10. 10.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 13 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  11. 11.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  12. 12.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 210 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  13. 13.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 150 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  14. 14.🤖 “if (A AND B)” is true when … (a) both are false (b) both A and B are true (c) only A is true (d) only B is true
  15. 15.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 34 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  16. 16.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 36 °C. What happens?
    (a) fan OFF (b) fan ON
  17. 17.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 37 %. What happens?
    (a) pump ON (b) pump OFF
  18. 18.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 28 °C. What happens?
    (a) fan ON (b) fan OFF
  19. 19.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 18 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  20. 20.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 30 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  21. 21.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 423. What happens?
    (a) lamp OFF (b) lamp ON
  22. 22.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 45 °C. What is shown?
    (a) Warm (b) Cool (c) Hot
  23. 23.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 264. What happens?
    (a) lamp ON (b) lamp OFF
  24. 24.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 13 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  25. 25.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 34 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  26. 26.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 293. What happens?
    (a) lamp OFF (b) lamp ON
  27. 27.🤖 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 ON (b) porch lamp OFF
  28. 28.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 25 °C. What happens?
    (a) fan OFF (b) fan ON
  29. 29.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 320 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  30. 30.🤖 if (light < 400 AND 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
  31. 31.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  32. 32.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 590 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  33. 33.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 15 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  34. 34.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 37 %. What happens?
    (a) pump ON (b) pump OFF
  35. 35.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 330 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  36. 36.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 57. What happens?
    (a) green LED ON (b) red LED ON
  37. 37.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 110 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  38. 38.🤖 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
  39. 39.🤖 if (light < 300) { lamp ON } else { lamp OFF }
    The light sensor reads 236. What happens?
    (a) lamp ON (b) lamp OFF
  40. 40.🤖 if (light < 200) { lamp ON } else { lamp OFF }
    The light sensor reads 101. What happens?
    (a) lamp ON (b) lamp OFF

Answer key

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

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