Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Microsoft/pxt-sonar
A Microsoft MakeCode package to handle sonar sensors and pings
https://github.com/Microsoft/pxt-sonar
Last synced: 3 months ago
JSON representation
A Microsoft MakeCode package to handle sonar sensors and pings
- Host: GitHub
- URL: https://github.com/Microsoft/pxt-sonar
- Owner: microsoft
- License: mit
- Created: 2016-08-17T18:21:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-13T20:56:45.000Z (about 1 year ago)
- Last Synced: 2024-04-02T13:13:08.391Z (3 months ago)
- Language: TypeScript
- Homepage: https://makecode.microbit.org/pkg/Microsoft/pxt-sonar
- Size: 67.4 KB
- Stars: 42
- Watchers: 16
- Forks: 33
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Lists
- awesome-microbit-zh - Sonar - 超声波传感器的pxt驱动. (编程 / JavaScript 和 MakeCode)
README
# pxt-sonar [![Build Status](https://travis-ci.org/Microsoft/pxt-sonar.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-sonar)
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.
```sig
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.
```blocks
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](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.