Skip to content

Commit 88ba25b

Browse files
committed
add example
1 parent e2ed4eb commit 88ba25b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,27 @@ This is easily achieved by downloading
2929
Usage Example
3030
=============
3131

32-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
32+
.. code-block:: python
33+
34+
import time
35+
import board
36+
import busio
37+
import adafruit_lidarlite
38+
39+
# Create library object using our Bus I2C port
40+
i2c = busio.I2C(board.SCL, board.SDA)
41+
42+
# Default configuration, with only i2c wires
43+
sensor = adafruit_lidarlite.LIDARLite(i2c)
44+
45+
while True:
46+
try:
47+
# We print tuples so you can plot with Mu Plotter
48+
print((sensor.distance,))
49+
except RuntimeError as e:
50+
# If we get a reading error, just print it and keep truckin'
51+
print(e)
52+
time.sleep(0.01) # you can remove this for ultra-fast measurements!
3353
3454
Contributing
3555
============

0 commit comments

Comments
 (0)