help display to lcd

Hi all. I have an hmc5883L Mag and when i load the sketch and go to the serial monitor the degrees are perfect. I want to put the degrees onto an LCD screen but cant for the love of god find anywhere to show me the code or how to print to the lcd.

The code I am using is:

#include <Wire.h> //I2C Arduino Library
#include <LiquidCrystal.h>
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
LiquidCrystal lcd(8, 7, 5, 4, 3, 2);
int i = 0;
int cnt=0;
int x,y,z;
long xx,yy,zz;

void setup(){
lcd.begin(20, 4);
Serial.begin(9600);
Wire.begin();
//Put the HMC5883 IC into the correct operating mode
Wire.beginTransmission(address); //open communication with HMC5883
Wire.write(0x02); //select mode register
Wire.write(0x00); //continuous measurement mode
Wire.endTransmission();
}
void loop(){
//Tell the HMC5883 where to begin reading data
Wire.beginTransmission(address);
Wire.write(0x03); //select register 3, X MSB register
Wire.endTransmission();
//Read data from each axis, 2 registers per axis
Wire.requestFrom(address, 6);
if(6<=Wire.available()){
x = Wire.read()<<8; //X msb
x |= Wire.read(); //X lsb
z = Wire.read()<<8; //Z msb
z |= Wire.read(); //Z lsb
y = Wire.read()<<8; //Y msb
y |= Wire.read(); //Y lsb
}
/*
//Print out values of each axis
Serial.print("x: “);
Serial.print(x);
Serial.print(” y: “);
Serial.print(y);
Serial.print(” z: ");
Serial.println(z);
/
//Serial.print(z);Serial.write(32);
//repeatable within 1 deg, but off by 90 deg?
if(avgxyz())
if(zz>4800){ //near level 5200 max down, in MA
//Serial.print(xx);Serial.write(32);Serial.println(yy);
float heading=atan2(yy,xx);
heading
=(180/M_PI);
//declination here degrees
if(heading<0)heading+=360;
if(heading>360)heading-=360; //for + declination only
//upside down on board so…
heading=360-heading;
Serial.println(heading);
}
delay(50); //50 or 150 more acc 3s
}
boolean avgxyz(){
const int N=20; //matches delay 2050=1s
boolean b;
cnt++;
if(cnt%N==1)xx=yy=zz=0;
xx+=x;
yy+=y;
zz+=z;
if(b=!(cnt%N)){
xx=xx
10/N;yy=yy10/N;zz=zz10/N; }
return(b);

}

I dont know anything about the code, i copied it from the net but it works perfect for me and just need to print to a lcd

You're including LiquidCrystal.h and you're creating an instance called lcd right there at the top. For the most part, the print statements will look just like the serial.print statements you already have except they'll say lcd.print. You'll also have to worry about something new which is where your cursor is and what is already on the screen. That part is up to you, but all the commands for it are in that LiquidCrystal library.

http://arduino.cc/en/Tutorial/LiquidCrystal

maximus999: I dont know anything about the code

There's a big part of the problem. The first thing you should do when copying any code is figure out how it works. Code you don't understand can be used for exactly what it was written for, but adding anything to it or taking anything away from it is a nightmare.

Delta, i know what your saying, it is a total mine field for me at the moment and their seems to be a few different ways to compile code for a certain thing, there is also no way of learning this stuff to my knowledge, there is a few people saying to me study the code and see how it works but it means nothing to me as i cant digest it.

if you are a complete beginner like me then there are probably a few things people need to know before being able to help.

Firstly have you got the LCD working, i.e does it light up and you are able to see the blocks of light? If not then that is step 1 to be fixed

If you have then you are only a couple of lines of code away from getting an output to it. You have created and instance of the LCD called lcd with this line of code LiquidCrystal lcd(8, 7, 5, 4, 3, 2); the code for manipulating text put the LCD is very similar to the serial commands lcd.clear() clears the screen lcd.setCursor() you guessed it, positions where the cursor is lcd.print() will print the text from the position you set the cursor to

As for learning and how to do it, I am only a couple of weeks into this myself and appreciate how difficult you might be finding it, sources I have used are this forum(although not often as first resort) you tube has lots of people using Arduinos with some great videos and they even go through their code and have examples on external web site you can download.

I would suggest taking a step back from where you are and start with a blank sketch with a setup and loop only and just mess around with moving the lcd cursor around and printing to it.

one of the biggest hurdles I have had with the codeing and I still forget and do it all the time is = does not mean = to something it sets something = to the value you provide == checks if something is equal to something else. e.g.

if (x=1) suggests in english you are checking to see if x is equal to 1 however that line of code ignores the fact you are asking if and set x equal to 1 whether you like it or not

the correct line of code is

if (x==1) this is checking to see if x is equal to 1.

hope that helps, which I could drill it into my head!!!

Dexter