CMPS03 Compass HelloWorld Program
This program is an example of how to use the CMPS03 compass library.
People may also use the CMPS03 I2C library that can be found in Mbed component section.
main.cpp
- Committer:
- haarkon
- Date:
- 2018-06-01
- Revision:
- 2:4dae0a194d00
- Parent:
- 1:96861dcaec35
File content as of revision 2:4dae0a194d00:
#include "mbed.h" #include "CMPS03.h" Serial pc (PA_2, PA_3, 921600); //Create a serial link to PC DigitalOut led1 (PA_5); // Added Led1 for test purpose DigitalOut led2 (PD_2); // Added Led2 for test purpose DigitalOut disquette (PA_12); // Added baloon destructor command (without it, you might see baloon destructor motor be set to full speed) CMPS03 boussole (PC_4); // Added compass int main() { pc.printf ("\nHelloWorld\n\r"); // Welcome message led1 = 1; // Led1 is ON led2 = 0; // Led2 is OFF disquette = 0; // Switch baloon destructor to OFF while(1) { pc.printf("\r%5.2lf", boussole.getBearing()); // Get bearing informations led1 = !led1; // Switch Led1 led2 = !led2; // Switch Led2 wait (0.2); // Wait for 200ms } }