Approved content

The content below is provided by partner.

pxt-sonar 0.0.5 (microsoft/pxt-sonar) Fork me

A MakeCode package to use sonar sensors

pxt-sonar Build Status

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


This package contains a ping block that can return the distance to an obstacle detected by the sonar., 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 =, DigitalPin.P2, PingUnit.Inches);
    led.plotBarGraph(p, 0);



Supported targets

## 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 []( with any additional questions or comments.