send microbit compass data

Dependencies:   microbit

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "MicroBit.h"
00002 
00003 MicroBit uBit;
00004 MicroBitSerial serial(USBTX, USBRX);
00005 MicroBitI2C i2c(I2C_SDA0, I2C_SCL0); 
00006 
00007 MicroBitAccelerometer accelerometer(i2c); 
00008 
00009 MicroBitStorage storage; 
00010 
00011 MicroBitCompass compass(i2c, accelerometer, storage); 
00012 
00013 int main()
00014 {
00015     uBit.init();
00016 
00017     while (1) {
00018       int heading = compass.heading();
00019       serial.send((ManagedString)heading);
00020       uBit.sleep(500);
00021     }
00022     
00023     release_fiber();
00024 }
00025