Skip to content

Commit 910bf9b

Browse files
authored
Merge pull request #5 from kattni/example-update
Updated example code.
2 parents e1caa05 + 167c008 commit 910bf9b

File tree

3 files changed

+10
-34
lines changed

3 files changed

+10
-34
lines changed

docs/examples.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
Simple test
22
------------
33

4-
For I2C communications, ensure your device works with this simple test.
4+
For I2C or SPI communications, ensure your device works with this simple test.
55

66
.. literalinclude:: ../examples/l3gd20_simpletest.py
77
:caption: examples/l3gd20_simpletest.py
88
:linenos:
9-
10-
For SPI communications, ensure your device works with this simple test.
11-
12-
.. literalinclude:: ../examples/l3gd20_spi_simpletest.py
13-
:caption: examples/l3gd20_spi_simpletest.py
14-
:linenos:

examples/l3gd20_simpletest.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import time
2-
from board import SCL, SDA
2+
import board
33
import busio
44
import adafruit_l3gd20
55

6-
# define the I2C wires
7-
I2C = busio.I2C(SCL, SDA)
8-
# initialize the device
6+
# Hardware I2C setup:
7+
I2C = busio.I2C(board.SCL, board.SDA)
98
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C)
109

11-
while True:
10+
# Hardware SPI setup:
11+
# import digitalio
12+
# CS = digitalio.DigitalInOut(board.D5)
13+
# SPIB = busio.SPI(board.SCK, board.MOSI, board.MISO)
14+
# SENSOR = adafruit_l3gd20.L3GD20_SPI(SPIB, CS)
1215

16+
while True:
1317
print('Acceleration (m/s^2): {}'.format(SENSOR.acceleration))
14-
1518
print()
16-
1719
time.sleep(1)

examples/l3gd20_spi_simpletest.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)