← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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