Basic example showing how to use the Gyroscope (L3GD20 device) present on DISCO_L476VG board.

Dependencies:   GYRO_DISCO_L476VG BSP_DISCO_L476VG

main.cpp

Committer:
Jerome Coutant
Date:
2019-11-20
Revision:
4:25b2a1150cd0
Parent:
0:5432bdf904f9

File content as of revision 4:25b2a1150cd0:

#include "mbed.h"
#include "GYRO_DISCO_L476VG.h"

GYRO_DISCO_L476VG gyro;

DigitalOut led1(LED1);

int main()
{
    float GyroBuffer[3];
  
    printf("Gyroscope started\n");
  
    while(1) {
        // Read Gyroscope values
        gyro.GetXYZ(GyroBuffer);
        // Display values      
        printf("X = %f\n", GyroBuffer[0]);
        printf("Y = %f\n", GyroBuffer[1]);
        printf("Z = %f\n", GyroBuffer[2]);
        printf("\033[3A"); // Moves cursor up x lines (x value is between [ and A)
        led1 = !led1;
        wait(1);
    }
}