Skip to content

Changing sensors in code #6

@brightproject

Description

@brightproject

Hello @pronenewbits
I want to use gyroscope and accelerometer sensors like lsm303dlh and l3gd20.
How to find the “entry point” to insert your own acceleration and angular velocity values into the code?
I get the raw data something like this:

#include <Wire.h>
#include <L3G.h>
#include <LSM303.h>

LSM303 mag_accel;
L3G gyro;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  if (!gyro.init())
  {
    Serial.println("Failed to autodetect gyro type!");
    while (1);
  }
  if (!mag_accel.init())
  {
    Serial.println("Failed to initialize mag_accel!");
    while (1);
  }
  gyro.enableDefault();
  mag_accel.enableDefault(); 
}

void loop() {

  gyro.read();
  mag_accel.read();

Serial.print(gyro.g.x);
Serial.print(",");
Serial.print(gyro.g.y);
Serial.print(",");
Serial.print(gyro.g.z);
Serial.print(",");
Serial.print(mag_accel.a.x);
Serial.print(",");
Serial.print(mag_accel.a.y);
Serial.print(",");
Serial.println(mag_accel.a.z);

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions