← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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