Steveiboy:
If Your not using and I2C LCD and using the standard LCD connections then you could try this,
It compiles and not tested as I don't have a normal LCD set up only I2C
But once you have set up your LCD you just reaplce Serial.print with LCD.print once you have set the cursor.
You could have a look here and get your LCD up and running with the link below
https://www.arduino.cc/en/Tutorial/HelloWorld?from=Tutorial.LiquidCrystal
Here is the code you could try has you've not said how your LCD is connected
/*
LiquidCrystal Library
The circuit:
LCD RS pin to digital pin 12
LCD Enable pin to digital pin 11
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 4
LCD D6 pin to digital pin 3
LCD D7 pin to digital pin 2
LCD R/W pin to ground
LCD VSS pin to ground
LCD VCC pin to 5V
10K resistor:
ends to +5V and ground
wiper to LCD VO pin (pin 3)
*/
// include the library code:
#include <LiquidCrystal.h>
#include<Wire.h>
const int MPU_addr = 0x68;
int16_t axis_X, axis_Y, axis_Z;
int minVal = 265;
int maxVal = 402;
double x;
double y;
double z;
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Wire.begin();
lcd.begin(16, 2);
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr, 14, true);
axis_X = Wire.read() << 8 | Wire.read();
axis_Y = Wire.read() << 8 | Wire.read();
axis_Z = Wire.read() << 8 | Wire.read();
int xAng = map(axis_X, minVal, maxVal, -90, 90);
int yAng = map(axis_Y, minVal, maxVal, -90, 90);
int zAng = map(axis_Z, minVal, maxVal, -90, 90);
x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI);
y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);
z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI);
lcd.setCursor(0, 1);
lcd.print("Angle of X axis = ");
lcd.print(x,2);
lcd.setCursor(0, 2);
lcd.print((char)176);
Serial.print("Angle of inclination in X axis = ");
Serial.print(x);
Serial.println((char)176);
/* Serial.print("Angle of inclination in Y axis= ");
Serial.print(y);
Serial.println((char)176);
Serial.print("Angle of inclination in Z axis= ");
Serial.print(z);
Serial.println((char)176);*/
Serial.println("-------------------------------------------");
delay(1000);
}
thanks a ton mate!
it worked