← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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