Exemplo n.º 1
0
import adafruit_l3gd20

from busio import I2C
from board import SDA, SCL

i2c = I2C(SCL, SDA)

sensor = adafruit_l3gd20.L3GD20_I2C(i2c)

while (True):
    print(sensor.gyro)
import time
from board import SCL, SDA
import busio
import adafruit_l3gd20

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

while True:

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

    print()

    time.sleep(1)
Exemplo n.º 3
0
import numpy
import math
import time
import board
import busio
import adafruit_l3gd20
import adafruit_lsm303
import matplotlib.pyplot as plt

outf = open('output.txt', 'a')
outf.truncate(0)

# Hardware I2C setup:
I2C = busio.I2C(board.SCL, board.SDA)
sensorGyro = adafruit_l3gd20.L3GD20_I2C(I2C)
sensorCompass = adafruit_lsm303.LSM303(I2C)
sensorCompass.mag_rate = adafruit_lsm303.MAGRATE_220

accsX = []
accsY = []
accsZ = []
counter = 0

angles = numpy.arange(-90, 100, 10)
xReals = []
yReals = []


def readAngle():
    acc_x, acc_y, acc_z = sensorCompass.acceleration
    acc_z -= 0.74
Exemplo n.º 4
0
        print("Bergab!")
        FAHRGESCHWINDIGKEIT = 30
    elif beschleunigung_x <= -3:
        print("Bergauf!")
        FAHRGESCHWINDIGKEIT = 75
    else:
        FAHRGESCHWINDIGKEIT = 50

def scale(wert, a, b, c, d):
    wert = (wert-a)*((d-c)/(b-a))+c
    return wert

try:
    i2c_bus = busio.I2C(board.SCL, board.SDA)
    beschl_kompass_sensor = adafruit_lsm303.LSM303(i2c_bus)
    gyro_sensor = adafruit_l3gd20.L3GD20_I2C(i2c_bus)

    kamera = PiCamera(resolution=(PIXEL_BREITE, PIXEL_HOEHE), framerate=32)
    speichert_einen_frame = numpy.empty((PIXEL_HOEHE, PIXEL_BREITE, 3), dtype=numpy.uint8)
    
    motorsteuerung = AFMotorShield(
        pin_clk=23,
        pin_data=6,
        pin_enable=5,
        pin_latch=26
    )

    motor_links = DCMotor(motorsteuerung, 2,
        pwm_pin=22,
        reversed=True
    )