← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 513 · 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) the else part (c) neither part (d) both parts
  2. 2.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 24 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  3. 3.🤖 “if (A AND B)” is true when … (a) only A is true (b) both are false (c) only B is true (d) both A and B are true
  4. 4.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 629. What happens?
    (a) lamp ON (b) lamp OFF
  5. 5.🤖 if (moisture < 40) { pump ON } else { pump OFF }
    The soil moisture sensor reads 35 %. What happens?
    (a) pump ON (b) pump OFF
  6. 6.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 17 °C. What happens?
    (a) fan OFF (b) fan ON
  7. 7.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 602. What happens?
    (a) lamp OFF (b) lamp ON
  8. 8.🤖 if (distance < 30) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 34 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  9. 9.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 10 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  10. 10.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 500 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  11. 11.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 41. What happens?
    (a) red LED ON (b) green LED ON
  12. 12.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  13. 13.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 39 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  14. 14.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 80 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  15. 15.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 28 °C. What happens?
    (a) fan OFF (b) fan ON
  16. 16.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 12 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  17. 17.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 74. What happens?
    (a) red LED ON (b) green LED ON
  18. 18.🤖 if (temperature > 37) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 22 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  19. 19.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 41 %. What happens?
    (a) pump ON (b) pump OFF
  20. 20.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 220 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  21. 21.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 25 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  22. 22.🤖 if (light < 400 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 300 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  23. 23.🤖 if (temperature > 34) { show “Hot” } else if (temperature > 24) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  24. 24.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 55. What happens?
    (a) green LED ON (b) red LED ON
  25. 25.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 80 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  26. 26.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 17 %. What happens?
    (a) pump ON (b) pump OFF
  27. 27.🤖 if (light < 400 OR 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
  28. 28.🤖 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
  29. 29.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 1 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  30. 30.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 110 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 39 %. What happens?
    (a) pump OFF (b) pump ON
  32. 32.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 18) { show “Warm” } else { show “Cool” }
    The temperature is 10 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  33. 33.🤖 if (sound > 60) { red LED ON } else { green LED ON }
    The sound sensor reads 58. What happens?
    (a) red LED ON (b) green LED ON
  34. 34.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  35. 35.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 340 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  36. 36.🤖 if (sound > 70) { red LED ON } else { green LED ON }
    The sound sensor reads 68. What happens?
    (a) red LED ON (b) green LED ON
  37. 37.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 10 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  38. 38.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 12 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  39. 39.🤖 if (sound > 80) { red LED ON } else { green LED ON }
    The sound sensor reads 86. What happens?
    (a) green LED ON (b) red LED ON
  40. 40.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 44 °C. What is shown?
    (a) Hot (b) Warm (c) Cool

Answer key

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

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