mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 17:46:19 +00:00
Now that each device is on its own page, we no longer need to collapse snippets to reduce page size. Now they can just all be at the bottom of the page. This also gives each a dedicated link which is easier when giving support.
37 lines
957 B
ReStructuredText
37 lines
957 B
ReStructuredText
Ultrasonic Sensor
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
.. figure:: ../../api/images/sensor_ultrasonic_lights_label.png
|
|
:width: 80 %
|
|
|
|
.. autoclass:: pybricks.pupdevices.UltrasonicSensor
|
|
:no-members:
|
|
|
|
.. automethod:: pybricks.pupdevices.UltrasonicSensor.distance
|
|
|
|
.. automethod:: pybricks.pupdevices.UltrasonicSensor.presence
|
|
|
|
.. rubric:: Built-in lights
|
|
|
|
This sensor has 4 built-in lights. You can adjust the brightness of each
|
|
light.
|
|
|
|
.. automethod:: pybricks.pupdevices::UltrasonicSensor.lights.on
|
|
|
|
.. automethod:: pybricks.pupdevices::UltrasonicSensor.lights.off
|
|
|
|
Examples
|
|
-------------------
|
|
|
|
Measuring distance and switching on the lights
|
|
**********************************************
|
|
|
|
.. literalinclude::
|
|
../../../examples/pup/sensor_ultrasonic/basics.py
|
|
|
|
Gradually change the brightness of the lights
|
|
**********************************************
|
|
|
|
.. literalinclude::
|
|
../../../examples/pup/sensor_ultrasonic/math.py
|