Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.
microsoftPublic archive

About

A Microsoft MakeCode package to handle sonar sensors and pings

Resources

Code of conduct

Security policy

Stars

47 stars

Watchers

13 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

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

  • for PXT/microbit
  • for PXT/calliope

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

About

A Microsoft MakeCode package to handle sonar sensors and pings

Resources

Code of conduct

Security policy

Stars

47 stars

Watchers

13 watching

Forks

Releases

Packages

Contributors

Languages