Recent changes
Slingshot user guide
tag Guide, user
NFCLamp user guide
tag Guide, user
Homepage
MPL115A2
Compiler Error 42
From the mbed microcontroller Cookbook.  

CMPS03 Digital Compass

http://mbed.org/media/uploads/aberk/cmps03.jpeg

The CMPS03 is a digital compass with an I2C interface.

Hello World!

» Import this program

00001 #include "CMPS03.h"
00002 
00003 CMPS03 compass(p9, p10, CMPS03_DEFAULT_I2C_ADDRESS);
00004 Serial pc(USBTX, USBRX);
00005 
00006 int main() {
00007 
00008     pc.printf("Starting CMPS03 test...\n");
00009 
00010     while(1){
00011         
00012         wait(0.1);
00013         
00014         pc.printf("Bearing is: %f\n", compass.readBearing() / 10.0);
00015     
00016     }
00017 
00018 }

Wiring

CMPS03 Pinmbed Pin
+5VVout
0v GndGnd
SCLp10
SDAp9

API

» Import this library into a program

Public Member Functions

CMPS03 (PinName sda, PinName scl, int address)
Constructor.
char readSoftwareRevision (void)
Reads the software revision register [register 0] on the device.
int readBearing (void)
Reads the current bearing of the compass.

Library

» Import this library into a programCMPS03

CMPS03 digital compass library.

Reference




calendar Page history
Last modified 27 Nov 2010, by   user Aaron Berk   tag No tags | 2 comments  

2 comments on CMPS03 Digital Compass:

17 Sep 2010

This module needs the two external I2C pull-up resistors - some other I2C modules have them on the board. See data sheet for suggested values.

23 Nov 2010

Would it not make sense to change <code>CMPS03_DEFAULT_I2C_ADDRESS</code> to <code>CMPS03::DEFAULT_I2C_ADDRESS</code>?

Please login to post comments.