Skip to content

Updated example code. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
Simple test
------------

For I2C communications, ensure your device works with this simple test.
For I2C or SPI communications, ensure your device works with this simple test.

.. literalinclude:: ../examples/l3gd20_simpletest.py
:caption: examples/l3gd20_simpletest.py
:linenos:

For SPI communications, ensure your device works with this simple test.

.. literalinclude:: ../examples/l3gd20_spi_simpletest.py
:caption: examples/l3gd20_spi_simpletest.py
:linenos:
16 changes: 9 additions & 7 deletions examples/l3gd20_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import time
from board import SCL, SDA
import board
import busio
import adafruit_l3gd20

# define the I2C wires
I2C = busio.I2C(SCL, SDA)
# initialize the device
# Hardware I2C setup:
I2C = busio.I2C(board.SCL, board.SDA)
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C)

while True:
# Hardware SPI setup:
# import digitalio
# CS = digitalio.DigitalInOut(board.D5)
# SPIB = busio.SPI(board.SCK, board.MOSI, board.MISO)
# SENSOR = adafruit_l3gd20.L3GD20_SPI(SPIB, CS)

while True:
print('Acceleration (m/s^2): {}'.format(SENSOR.acceleration))

print()

time.sleep(1)
20 changes: 0 additions & 20 deletions examples/l3gd20_spi_simpletest.py

This file was deleted.