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

Dependencies:   BSP_DISCO_F429ZI GYRO_DISCO_F429ZI mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "GYRO_DISCO_F429ZI.h"
00003 
00004 GYRO_DISCO_F429ZI gyro;
00005 
00006 DigitalOut led1(LED1);
00007 
00008 int main()
00009 {
00010     float GyroBuffer[3];
00011   
00012     printf("Gyroscope started\n");
00013   
00014     while(1) {
00015         // Read Gyroscope values
00016         gyro.GetXYZ(GyroBuffer);
00017         // Display values      
00018         printf("X = %f\n", GyroBuffer[0]);
00019         printf("Y = %f\n", GyroBuffer[1]);
00020         printf("Z = %f\n", GyroBuffer[2]);
00021         printf("\033[3A"); // Moves cursor up x lines (x value is between [ and A)
00022         led1 = !led1;
00023         wait(1);
00024     }
00025 }