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 LCD_DISCO_L476VG mbed
Fork of DISCO_L476VG_Compass_Lab_6 by
main.cpp
- Committer:
- bcostm
- Date:
- 2015-09-22
- Revision:
- 0:211cb2effe6e
- Child:
- 4:b5850ba75275
File content as of revision 0:211cb2effe6e:
#include "mbed.h"
#include "COMPASS_DISCO_L476VG.h"
COMPASS_DISCO_L476VG compass;
DigitalOut led1(LED1);
int main()
{
int16_t MagBuffer[3];
int16_t AccBuffer[3];
printf("Compass started\n");
while(1) {
// Read acceleremoter and magnetometer values
compass.AccGetXYZ(AccBuffer);
compass.MagGetXYZ(MagBuffer);
// Display values
printf("Acc X = %d\n", AccBuffer[0]);
printf("Acc Y = %d\n", AccBuffer[1]);
printf("Acc Z = %d\n", AccBuffer[2]);
printf("Mag X = %d\n", MagBuffer[0]);
printf("Mag Y = %d\n", MagBuffer[1]);
printf("Mag Z = %d\n", MagBuffer[2]);
printf("\033[6A"); // Moves cursor up x lines (x value is between [ and A)
led1 = !led1;
wait(1);
}
}
