File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,32 @@ This is easily achieved by downloading
28
28
Usage Example
29
29
=============
30
30
31
- .. todo :: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
31
+ .. code-block :: python
32
+
33
+ import time
34
+ import board # comment this out if using pyserial
35
+ import busio # comment this out if using pyserial
36
+ import adafruit_tfmini
37
+
38
+ # Use hardware uart
39
+ uart = busio.UART(board.TX , board.RX )
40
+
41
+ # Or, you can use pyserial on any computer
42
+ # import serial
43
+ # uart = serial.Serial("/dev/ttyS2", timeout=1)
44
+
45
+ # Simplest use, connect with the uart bus object
46
+ tfmini = adafruit_tfmini.TFmini(uart)
47
+
48
+ # You can put in 'short' or 'long' distance mode
49
+ tfmini.mode = adafruit_tfmini.MODE_SHORT
50
+ print (" Now in mode" , tfmini.mode)
51
+
52
+ while True :
53
+ print (" Distance: %d cm (strength %d , mode %x )" %
54
+ (tfmini.distance, tfmini.strength, tfmini.mode))
55
+ time.sleep(0.1 )
56
+
32
57
33
58
Contributing
34
59
============
You can’t perform that action at this time.
0 commit comments