CMPS03 Compass HelloWorld Program

Dependencies:   mbed CMPS03

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.

Files at this revision

API Documentation at this revision

Comitter:
haarkon
Date:
Fri Jun 01 07:06:28 2018 +0000
Parent:
1:96861dcaec35
Commit message:
Added comment

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 96861dcaec35 -r 4dae0a194d00 main.cpp
--- a/main.cpp	Fri Jun 01 06:57:41 2018 +0000
+++ b/main.cpp	Fri Jun 01 07:06:28 2018 +0000
@@ -1,26 +1,26 @@
 #include "mbed.h"
 #include "CMPS03.h"
 
-    Serial          pc          (PA_2, PA_3, 921600);
+    Serial          pc          (PA_2, PA_3, 921600);   //Create a serial link to PC
 
-    DigitalOut      led1        (PA_5);
-    DigitalOut      led2        (PD_2);
-    DigitalOut      disquette   (PA_12);
+    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);
+    CMPS03          boussole    (PC_4);                 // Added compass
 
 int main()
 {
 
-    pc.printf ("\nHelloWorld\n\r");
-    led1 = 1;
-    led2 = 0;
-    disquette = 0;
+    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());
-        led1 = !led1;
-        led2 = !led2;
-        wait (0.2);
+        pc.printf("\r%5.2lf", boussole.getBearing());   // Get bearing informations
+        led1 = !led1;                                   // Switch Led1
+        led2 = !led2;                                   // Switch Led2
+        wait (0.2);                                     // Wait for 200ms
     }
 }