test

Dependencies:   mbed QMC5883L ledControl

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "QMC5883L.h"
00003 
00004 QMC5883L qmc;
00005 
00006 DigitalOut myled(LED1);
00007 
00008 Serial pc(USBTX,USBRX);
00009 
00010 int main() {
00011     
00012 qmc.init();
00013 
00014 pc.baud(115200);
00015 
00016 while(1) {
00017     
00018 wait(0.001);
00019 
00020 int mgx=qmc.getMagXvalue();
00021 int mgy=qmc.getMagYvalue();
00022 int mgz=qmc.getMagZvalue();
00023 
00024 float mgxyz=sqrt(pow((float)mgx,2)+pow((float)mgy,2)+pow((float)mgz,2));
00025 pc.printf("%d,%d,%d,%7.0f\n\r",mgx,mgy,mgz,mgxyz);
00026 
00027 }
00028 }