QTI Line and Close-range Object Detection
The QTI is most often used as a robotic line sensor. It shines infrared light, and if a surface within about 1/4-inch reflects that light the script will respond with a smaller value. If the surface is black, it will absorb the light and respond with a larger value.

Parts
(1) QTI module 555-27401
(1) 3-Pin Signal-Power-Ground Cable Extension (8″) 800-00080 (Optional)
(1) 3-Pin Single Row Header (long) (451-00303) (Optional)
(1) Resistor 220 Ω (red-red-brown-gold)
Jumper wires: Red, black
Schematic

Wiring

Script
# qti-charge-time
from microbit import *
import machine
pin8.set_pull(pin8.NO_PULL)
while True:
pin8.write_digital(1)
sleep(1)
qt = machine.time_pulse_us(pin8, 1, 200000)
s = str(qt) + " us"
print(s)
display.scroll(s)
sleep(100)
Tests
The QTI is designed to face downwards close to either a black or white surface. Make sure it is not facing a window with sun streaming in or any other bright source of light.
Use a sharpie to create a black 1×1 inch black square in the corner of a sheet of paper.
Face that 1×1 inch black square 1/4 of an inch from the parts side of the QTI and note the measurement.
Now, face a corner the surface of a corner of the same sheet that white, again at a distance of 1/4 inch.
The microsecond time measurement should be less than 1/4 of the previous measurement.