Skip to content

Instantly share code, notes, and snippets.

@Robotonics
Created January 12, 2014 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robotonics/8378707 to your computer and use it in GitHub Desktop.
Save Robotonics/8378707 to your computer and use it in GitHub Desktop.
byte highByte;
byte lowByte;
?
Wire.beginTransmission(address); //starts communication with cmps03
Wire.write(2); //Sends the register we wish to read
Wire.endTransmission();
?
Wire.requestFrom(address, 2); //requests high byte
while(Wire.available() < 2); //while there is a byte to receive
highByte = Wire.read(); //reads the byte as an integer
lowByte = Wire.read();
int bearing = ((highByte<<8)+lowByte)/10;
double conversion = (bearing*3.14159)/180;
?
Serial.println(conversion,5);
delay(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment