A Microsoft MakeCode package to handle sonar sensors and pings
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.vscode refresh library Jun 16, 2017
.gitignore initial sonar package Aug 17, 2016
.travis.yml added travis info May 23, 2018
LICENSE.txt refresh library Jun 16, 2017
README.md updated search May 23, 2018
icon.png added travis info May 23, 2018
main.ts migrating to idiv May 1, 2018
pxt.json 0.0.5 May 23, 2018
test.ts refresh library Jun 16, 2017
tsconfig.json initial sonar package Aug 17, 2016

README.md

pxt-sonar Build Status

A MakeCode package to use sonar sensors (ping) such as the HC-SR04.

Usage

This package contains a ping block that can return the distance to an obstacle detected by the sonar.

sonar.ping(DigitalPin.P1, DigitalPin.P2, PingUnit.Inches);

Charting the distance

Use the plot bar graph block to visualize the distance reported by your sensor.

basic.forever(() => {
    let p = sonar.ping(DigitalPin.P1, DigitalPin.P2, PingUnit.Inches);
    led.plotBarGraph(p, 0);
})

License

MIT

Supported targets