Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_L476VG COMPASS_DISCO_L476VG
main.cpp
00001 #include "mbed.h" 00002 #include "COMPASS_DISCO_L476VG.h" 00003 00004 COMPASS_DISCO_L476VG compass; 00005 00006 DigitalOut led1(LED1); 00007 00008 int main() 00009 { 00010 int16_t MagBuffer[3]; 00011 int16_t AccBuffer[3]; 00012 00013 printf("Compass started (LD5 should blink)\n"); 00014 00015 while(1) { 00016 00017 // Read acceleremoter and magnetometer values 00018 compass.AccGetXYZ(AccBuffer); 00019 compass.MagGetXYZ(MagBuffer); 00020 // Display values 00021 printf("Acc X = %d\n", AccBuffer[0]); 00022 printf("Acc Y = %d\n", AccBuffer[1]); 00023 printf("Acc Z = %d\n", AccBuffer[2]); 00024 printf("Mag X = %d\n", MagBuffer[0]); 00025 printf("Mag Y = %d\n", MagBuffer[1]); 00026 printf("Mag Z = %d\n", MagBuffer[2]); 00027 printf("\033[6A"); // Moves cursor up x lines (x value is between [ and A) 00028 00029 led1 = !led1; 00030 ThisThread::sleep_for(1000); 00031 } 00032 }
Generated on Wed Jul 20 2022 10:10:04 by
1.7.2