https://github.com/fizban99/microbit_us100
Micro:bit library for the ultrasonic sensor us-100 in serial mode
https://github.com/fizban99/microbit_us100
microbit micropython us-100
Last synced: 6 months ago
JSON representation
Micro:bit library for the ultrasonic sensor us-100 in serial mode
- Host: GitHub
- URL: https://github.com/fizban99/microbit_us100
- Owner: fizban99
- License: mit
- Created: 2017-03-14T21:36:41.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-24T16:32:03.000Z (over 4 years ago)
- Last Synced: 2024-08-31T08:01:47.028Z (over 1 year ago)
- Topics: microbit, micropython, us-100
- Language: Python
- Size: 3.91 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-microbit-zh - US-100 - 通过UART从US-100 超声波传感器读取距离的基本MicroPython库。 (编程 / Python)
- awesome-microbit - US-100 - Library to read the distance from a US-100 ultrasonic sensor via UART. (🐍 Python / 🐍 MicroPython Libraries)
README
Basic micropython library to read the distance from an ultrasonic sensor US-100 in serial mode
##############################################################################################
This library allows the micro:bit to read the distance from an ultrasonic sensor US-100 (Y401)).
It uses the serial port to communicate with the device and to retrieve both the distance and temperature. By default it assumes pin15 connected to trigger/tx and pin14 connected to echo/rx
.. contents::
.. section-numbering::
Main features
=============
* Get the distance in mm from the sonar to an object.
* Get the temperture measured by the sensor.
* Sample program.
Library usage
=============
distance_mm()
+++++++++++++++++++++++
Get the distance in mm.
.. code-block:: python
from us100 import US100
from microbit import sleep
sonar=US100()
while True:
print('%.1f' % (sonar.distance_mm()/10))
sleep(1000)
temperature()
+++++++++++++++++++++++
Get the temperature from the sonar
.. code-block:: python
from us100 import US100
from microbit import sleep
sonar=US100()
while True:
print('%i' % sonar.temperature)
sleep(1000)