Object Sensor¶

Description |
Sometimes referred to as a Hunt Sensor. It contains an LED that emits Infrared (IR) light, and a Phototransistor that detects IR light reflected from nearby objects. Many uses such as object detection and line following. |
Usage |
Reads the IR reflected energy from an object. Outputs HIGH if object is detected. Outputs LOW if no object is detected. You can rotate the blue trimmer resistor with a screwdriver to adjust the sensitivity of the hunt sensor. NOTE: In some cases, the Object Sensor will not output a high enough value to trigger a digital output. You can always use the analog value and set the threshold yourself. |
Voltage Range |
3 - 5V |
Interface Type |
Digital Input |
Example Usage |
from microbit import *
# set pull to force the sensor to output digital
pin0.set_pull(pin0.PULL_UP)
while True:
hunt_val = pin0.read_digital()
if hunt_val == 1:
# object detected
# ...do something
else:
# NO object detected
# ...do something
|