Skip to content
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

Changing sensors in code #6

Open
brightproject opened this issue Nov 11, 2023 · 0 comments
Open

Changing sensors in code #6

brightproject opened this issue Nov 11, 2023 · 0 comments

Comments

@brightproject
Copy link

brightproject commented Nov 11, 2023

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);

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant