LaserPING Distance Sensor
The LaserPING sensor measures the time it takes infrared light to make a round trip from the laser ping, to an object, and back and sends it to the microcontroller as a pulse (a brief high signal). The amount of time the signal stays high indicates the time of flight.

Parts
(1) LaserPING 28041
(1) Resistor 220 Ω (red-red-brown-gold)
Jumper wires: Red, black
Schematic

Wiring

Script
# test-laserping-distance
from microbit import *
import machine
pin8.set_pull(pin8.NO_PULL)
pin8.write_digital(0)
while True:
pin8.write_digital(1)
pin8.write_digital(0)
t_pulse = machine.time_pulse_us(pin8, 1, 20000)
dist_cm = t_pulse * 0.01715
dist_in = t_pulse * 0.006752
s = "%.1f " % dist_cm + "cm, " +"%.1f " % dist_in + "in"
print(s)
display.scroll(s)
sleep(100)
Tests
Face the parts side of the laser ping at various target objects and compare their ruler measured distance to the micro:bit measured distance.