Professional Documents
Culture Documents
Digital Compass Using Devantech CMPS03
Digital Compass Using Devantech CMPS03
[gv data="L5Gi16C_t3I"][/gv]
Required Parts ;
I was searching through google the other day, and I wanted to build a digital compass for my car.
So I figured I’d first start messing with it by using a CUBLOC Study Board
since it has a nice little breadboard for proto-typing.
Connections:
Please make sure to connect Pull-Up resistors 4.7K to P31 and P30 as shown below:
Wait a Minute, MAX! What are the resistors for?
Looks fairly simple right? Let’s look at more in detail what these registers do.
As you can see, register 1 will return a value between 0 to 255 for a full circle.
Next, we will use CUBLOC BASIC to read both register 1, 2, and 3 to return
the current values of the digital compass.
Sub CompassSend()
Dim Value As Byte
Dim Degree As Integer
End Sub
The rest I think you will understand very easily just by looking at it.
Here, we use If Then Debug �ERROR� to check for acknowledgement of the I2C device, CMPS03
module.
The csgdec function is simply a system function for outputting to the seven segment display.
Simply compile and download this program to your CB280 module now.
If you start rotating your study board,
you will see that the seven segment display will change values in degrees between 0 and 360.