Proximity sensor

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Proximity sensor

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a proximity sensor detect?
A Whether an object is nearby, or how far away it is
B The temperature of the air around it
2. Does a proximity sensor need to touch an object to detect it?
A No, it detects the object without touching it
B Yes, it must press against the object
3. Which device is a use of a proximity sensor?
A Parking sensors that beep as a car gets close to a wall
B A greenhouse system that measures soil water
4. Why does a phone screen turn off during a call?
A A pH sensor detects that you are talking
B A proximity sensor detects the phone is held next to your face
5. Which sensor helps an automatic door open when someone walks up to it?
A Gas sensor
B Proximity sensor

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1if distance < 30: beep() Adistance = proximity_sensor.read()
2if object_near: screen_off() Bif person_near: open_door()
3A proximity sensor on an automatic door detects a person nearby without touching them, so the door opens CAn automatic door uses a proximity sensor, so the condition should test whether a person is near (person_near), not read a temperature value.
4A parking sensor captures the distance to an object, so the data can be a number, not just near or not near DReads the proximity sensor's distance value and sounds a warning when an object is closer than 30 cm, like a parking sensor
5if touched: screen_off() ETurns the phone screen off when the proximity sensor detects the phone is held against the face during a call
6if temperature > 30: open_door() FA proximity sensor detects an object nearby WITHOUT touching it, so the condition should check for a nearby object (for example object_near), not a touch.

Definitions

proximity sensor

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
distance ← _______________()
2.
IF distance _ 50 THEN OUTPUT "Beep" ENDIF
3.
IF onCall = TRUE ___ near = TRUE THEN ScreenOff() ENDIF
4.
IF objectNear = TRUE ____ OpenDoor() ENDIF
5.
distance ← ProximitySensor() IF ________ <= 30 THEN OUTPUT "Stop" ENDIF

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A REPEAT
B distance ← PROXIMITY_SENSOR()
C IF distance < 50
D SOUND_BUZZER()
E ENDIF
F UNTIL gear = "park"
Question 2
A door ← "closed"
B nearby ← PROXIMITY_SENSOR()
C IF nearby = TRUE THEN
D door ← "closed"
E ENDIF
Question 3
A ON call_start
B near ← PROXIMITY_SENSOR()
C IF near = FALSE THEN
D screen ← "off"
E ENDIF
Question 4
A distance ← PROXIMITY_SENSOR()
B IF distance < 100 THEN
C OUTPUT "Path is clear"
D ELSE
E OUTPUT "Path is clear"
F ENDIF
Question 5
A WHILE TRUE
B d ← PROXIMITY_SENSOR()
C IF d < 80 THEN
D MOTOR_OFF()
E ENDIF
F ENDWHILE

Answer Key

Proximity sensor
Section A: Quick Questions
Q1
A — Whether an object is nearby, or how far away it is
Q2
A — No, it detects the object without touching it
Q3
A — Parking sensors that beep as a car gets close to a wall
Q4
B — A proximity sensor detects the phone is held next to your face
Q5
B — Proximity sensor
Section B: Match the Pairs
Q1
if distance < 30: beep() → Reads the proximity sensor's distance value and sounds a warning when an object is closer than 30 cm, like a parking sensor
Q2
if object_near: screen_off() → Turns the phone screen off when the proximity sensor detects the phone is held against the face during a call
Q3
A proximity sensor on an automatic door detects a person nearby without touching them, so the door opens → if person_near: open_door()
Q4
A parking sensor captures the distance to an object, so the data can be a number, not just near or not near → distance = proximity_sensor.read()
Q5
if touched: screen_off() → A proximity sensor detects an object nearby WITHOUT touching it, so the condition should check for a nearby object (for example object_near), not a touch.
Q6
if temperature > 30: open_door() → An automatic door uses a proximity sensor, so the condition should test whether a person is near (person_near), not read a temperature value.
Section C: Definitions
Q1
proximity sensor — A sensor that detects whether an object is nearby, or how far away it is, without touching it. Used in parking sensors, phones turning off the screen during calls and automatic doors.
Section D: Fill in the Blanks
Q1
distance ← ProximitySensor()
Q2
IF distance < 50 THEN OUTPUT "Beep" ENDIF
Q3
IF onCall = TRUE AND near = TRUE THEN ScreenOff() ENDIF
Q4
IF objectNear = TRUE THEN OpenDoor() ENDIF
Q5
distance ← ProximitySensor() IF distance <= 30 THEN OUTPUT "Stop" ENDIF
Section E: Spot the Error
Q1
C — An IF statement must end with THEN. The line should be: IF distance < 50 THEN.
Q2
D — When the proximity sensor detects someone nearby, the automatic door should open. The line should be: door ← "open".
Q3
C — The screen should turn off when the phone is near the ear, so the test must be near = TRUE, not FALSE.
Q4
C — This branch runs when the distance is small, so an object is close. The message should be: OUTPUT "Object is close".
Q5
D — When the sensor detects a person close to the door, the microprocessor must switch the motor on to open it. It should be MOTOR_ON().