← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

Electronics lesson 24: If / else with sensors · Set 408 · 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 < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 69 %. What happens?
    (a) pump OFF (b) pump ON
  2. 2.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 17 %. What happens?
    (a) pump OFF (b) pump ON
  3. 3.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 10 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  4. 4.🤖 if (temperature > 28) { fan ON } else { fan OFF }
    The temperature sensor reads 35 °C. What happens?
    (a) fan OFF (b) fan ON
  5. 5.🤖 if (light < 200 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 150 and motion is detected (true). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  6. 6.🤖 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
  7. 7.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 28 °C. What happens?
    (a) fan OFF (b) fan ON
  8. 8.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 11 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  9. 9.🤖 if (light < 300 OR motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 120 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  10. 10.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 460 and motion is detected (true). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  11. 11.🤖 if (temperature > 30) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 34 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  12. 12.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  13. 13.🤖 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
  14. 14.🤖 if (temperature > 32) { fan ON } else { fan OFF }
    The temperature sensor reads 26 °C. What happens?
    (a) fan OFF (b) fan ON
  15. 15.🤖 if (light < 200 AND 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
  16. 16.🤖 if (moisture < 30) { pump ON } else { pump OFF }
    The soil moisture sensor reads 15 %. What happens?
    (a) pump OFF (b) pump ON
  17. 17.🤖 “if (A AND B)” is true when … (a) both A and B are true (b) both are false (c) only A is true (d) only B is true
  18. 18.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 26 °C. What is shown?
    (a) Hot (b) Cool (c) Warm
  19. 19.🤖 if (temperature > 30) { fan ON } else { fan OFF }
    The temperature sensor reads 37 °C. What happens?
    (a) fan ON (b) fan OFF
  20. 20.🤖 if (light < 500) { lamp ON } else { lamp OFF }
    The light sensor reads 626. What happens?
    (a) lamp OFF (b) lamp ON
  21. 21.🤖 if (light < 200 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 570 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  22. 22.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 14 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  23. 23.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 14 °C. What is shown?
    (a) Cool (b) Warm (c) Hot
  24. 24.🤖 if (light < 400 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
  25. 25.🤖 if (temperature > 32) { show “Hot” } else if (temperature > 20) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  26. 26.🤖 if (temperature > 31) { show “Hot” } else if (temperature > 19) { show “Warm” } else { show “Cool” }
    The temperature is 30 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  27. 27.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 12 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  28. 28.🤖 if (light < 300 OR 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
  29. 29.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 15 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  30. 30.🤖 if (temperature > 33) { show “Hot” } else if (temperature > 23) { show “Warm” } else { show “Cool” }
    The temperature is 15 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  31. 31.🤖 if (moisture < 50) { pump ON } else { pump OFF }
    The soil moisture sensor reads 35 %. What happens?
    (a) pump OFF (b) pump ON
  32. 32.🤖 if (distance < 20) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 28 cm. What happens?
    (a) buzzer is silent (b) buzzer beeps
  33. 33.🤖 if (temperature > 36) { show “Hot” } else if (temperature > 22) { show “Warm” } else { show “Cool” }
    The temperature is 20 °C. What is shown?
    (a) Hot (b) Warm (c) Cool
  34. 34.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 11 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  35. 35.🤖 if (distance < 10) { buzzer beeps } else { buzzer is silent }
    The distance sensor reads 19 cm. What happens?
    (a) buzzer beeps (b) buzzer is silent
  36. 36.🤖 if (temperature > 35) { show “Hot” } else if (temperature > 26) { show “Warm” } else { show “Cool” }
    The temperature is 16 °C. What is shown?
    (a) Cool (b) Hot (c) Warm
  37. 37.🤖 if (temperature > 38) { show “Hot” } else if (temperature > 25) { show “Warm” } else { show “Cool” }
    The temperature is 28 °C. What is shown?
    (a) Warm (b) Hot (c) Cool
  38. 38.🤖 if (light < 400 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 410 and motion is not detected (false). What happens?
    (a) porch lamp OFF (b) porch lamp ON
  39. 39.🤖 if (light < 300 AND motion) { porch lamp ON } else { porch lamp OFF }
    The light reading is 370 and motion is not detected (false). What happens?
    (a) porch lamp ON (b) porch lamp OFF
  40. 40.🤖 if (temperature > 25) { fan ON } else { fan OFF }
    The temperature sensor reads 33 °C. What happens?
    (a) fan ON (b) fan OFF

Answer key

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

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