HenryKit basic extension for MakeCode micro:bit!
This repository can be added as an extension in MakeCode:
- open https://makecode.microbit.org
- click on New Project
- click on Extensions under the gearwheel menu
- search for https://github.com/arduino12/pxt_henrykit_basic and import
||init [trig] [echo]||
Initialize the sonar
object, can be called this from on start
and set different pinout.
henrykit.sonar.init(
trig: DigitalPin=DigitalPin.P2,
echo: DigitalPin=DigitalPin.P1,
maxCmDistance: number=300,
updateMs: number=300
);
||distance (cm)||
Read the distance in centimeters.
henrykit.sonar.distance();
||on distance [range] [min] to [max] (cm)||
Do something when the sensor reading match the given range.
henrykit.onDistanceRange(
inOut: InOut=InOut.GotIn,
min: number=0,
max: number=20,
callback: () => void
);
Use the plot bar graph
block to visualize the distance reported by a sonar sensor.
basic.forever(function () {
led.plotBarGraph(henrykit.sonar.distance(), 0);
basic.pause(300);
})
MIT
A.E. Tech
- for PXT/microbit