Final Project

42 degrees SouthWest (if by any means we get there) prototype

 

IMG_8890 IMG_2634 IMG_2640 IMG_2643 IMG_2647

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Code:

 

 

Send:

#include <Wire.h> //I2C Arduino Library
//#include <LiquidCrystal.h>
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
//LiquidCrystal lcd(11,10,5,4,3,2);

 

void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
//lcd.begin(16, 2);
//lcd.setCursor(0,0);
//lcd.print(“x:”);
//lcd.setCursor(9,0);
//lcd.print(“y:”);
//lcd.setCursor(0,1);
//lcd.print(“z:”);

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(){

int x,y,z; //triple axis data

//Tell the HMC5883L 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
/* lcd.print(” “);
lcd.setCursor(3, 0);
lcd.print(x);
lcd.print(” “);
lcd.setCursor(12, 0);
lcd.print(y);
lcd.print(” “);
lcd.setCursor(3, 1);
lcd.print(z);
*/

//Serial.print(“x: “);
//Serial.print(x);
//Serial.print(” y: “);
//Serial.print(y);
//Serial.print(” z: “);
Serial.println(z);

delay(500);
}

 

 

 

RECEIVE:

 

//#include <Wire.h> //I2C Arduino Library
#include <LiquidCrystal.h>
//#define address 0x1E //0011110b, I2C 7bit address of HMC5883
LiquidCrystal lcd(11,10,5,4,3,2);
//int message = 0;
void setup(){
//Initialize Serial and I2C communications
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(“trueSW”);
//lcd.setCursor(9,0);
//lcd.print(“y:”);
//lcd.setCursor(0,1);
//lcd.print(“z:”);
lcd.setCursor(0,1);
lcd.print(“distance:s”);
}
/*
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()
{
// when characters arrive over the serial port…
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.setCursor(8,0);
lcd.write(Serial.read());
lcd.setCursor(10,1);
lcd.print(millis()/1000);

delay(250);
}
}
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

df

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: