コンテンツにスキップ

FaBo 201

認識の確認

1
sudo i2cdetect -r -y 8

パッケージのインストール

1
2
sudo pip install smbus
sudo pip install FaBo3Axis_ADXL345

サンプル

smbusが1ではなく、8になっている。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# coding: utf-8
import FaBo3Axis_ADXL345
import time
import sys

adxl345 = FaBo3Axis_ADXL345.ADXL345()

try:
    while True:
        axes = adxl345.read()
        sys.stdout.write("\rx = %f, y = %f, z = %f" % (axes['x'],  axes['y'], axes['z']))
        sys.stdout.flush()
        time.sleep(0.1)
except KeyboardInterrupt:
    sys.exit()