← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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