Elecrow on-line store, make your making easier.
https://www.elecrow.com/
Material:
Micro:bit
x1
Crowtail- Base Shield for Micro:bit
x1
Crowtail- IR Reflective Sensor
x1
Crowtail- Buzzer
x1
Lesson14. IR Distance Measurement
If we can make some tools that can measure the distance , it sounds very interesting .This Lesson
will teach you use IR to detect short distance. Connect the Crowtail- 80cm Infrared Proximity
Sensor to P0 interface, then upload code, aim the probe at the front object, you will view the
distance between the probe and the object, which show on the LED dot matrix.
Note
:
Distance measuring range: 10 cm to 80 cm
let
value =
0
basic
.
forever
(() => {
value =
pins
.
digitalReadPin
(DigitalPin.P0)
if
(value) {
pins
.
digitalWritePin
(DigitalPin.P1,
1
)
}
else
{
pins
.
digitalWritePin
(DigitalPin.P1,
0
)
}
})