I tried to combine it but fail to do so…): I tried combining the two void setup but after i do so the arduino won’t be able to display anything. No data or readings. I have using the altimu-10 v4 with the arduino uno. Below is one of the arduino sketch that i want to combine. The other one I made it as an attachment because it has a few sketches all together. Anyone there that help me combine? Thanks!
Here are my codes:
#include <Wire.h>
#include <LSM303.h>
#include <LPS.h>
#include <L3G.h>
#include <math.h>
L3G gyro;
LPS ps;
LSM303 compass;
char report[80];
float pressure;
float altitude;
float temperature;
float heading;
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}
gyro.enableDefault();
Serial.begin(9600);
Wire.begin();
if (!ps.init())
{
Serial.println("Failed to autodetect pressure sensor!");
while (1);
}
ps.enableDefault();
Serial.begin(9600);
Wire.begin();
compass.init();
compass.enableDefault();
}
void loop()
{
gyro.read();
//Serial.print("G ");
// Serial.print("X: ");
//Serial.print((int)gyro.g.x);
//Serial.print(" Y: ");
//Serial.print((int)gyro.g.y);
//Serial.print(" Z: ");
//Serial.println((int)gyro.g.z);
float pressure = ps.readPressureInchesHg();
float altitude = ps.pressureToAltitudeFeet(pressure);
float temperature = ps.readTemperatureF();
//Serial.print("p: ");
Serial.print(pressure);
//Serial.print(" inHg ");
//Serial.print(" ");
//Serial.print(altitude);
//Serial.print(" ft ");
//Serial.print(temperature);
//Serial.println(" deg C");
compass.read();
//snprintf(report, sizeof(report), "A: %6d %6d %6d M: %6d %6d %6d",
//compass.a.x, compass.a.y, compass.a.z,
//compass.m.x, compass.m.y, compass.m.z);
Serial.println(report);
delay(1000);
}
AHRS_v4_arduino.ino (4.86 KB)