Preston Stephens
/
Mini_Project_Day_7_Taps_2
Compass Working
Diff: Compass.cpp
- Revision:
- 2:ef6778c2438e
- Parent:
- 0:1acd78600f46
--- a/Compass.cpp Wed Jan 13 22:31:54 2016 +0000 +++ b/Compass.cpp Thu Jan 14 02:04:19 2016 +0000 @@ -5,19 +5,19 @@ short data[6]; short magComponents[3]; double heading; -const int addr = (0x1E << 1); +const int addr1 = (0x1E << 1); char config[2]; char init[2]; double Compass() { config[0]= 0x02; config[1] = 0x00; - i2c_port.write(addr, config,2); + i2c_port.write(addr1, config,2); init[0]=0x03; while(1) { - i2c_port.write(addr,init,1); - i2c_port.read(addr,rawBytes,6); + i2c_port.write(addr1,init,1); + i2c_port.read(addr1,rawBytes,6); for (int i = 0; i<6; i++) @@ -36,8 +36,7 @@ { heading -= 360; } - wait(.05); - + return heading; } }