← If / else with sensors lesson New set →

Electronics Worksheet: If Else with Sensors

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

Answer key

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

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