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

Dependencies:   BSP_DISCO_F429ZI GYRO_DISCO_F429ZI mbed

Committer:
bcostm
Date:
Fri Dec 18 14:39:20 2015 +0000
Revision:
0:44f624c5501e
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:44f624c5501e 1 #include "mbed.h"
bcostm 0:44f624c5501e 2 #include "GYRO_DISCO_F429ZI.h"
bcostm 0:44f624c5501e 3
bcostm 0:44f624c5501e 4 GYRO_DISCO_F429ZI gyro;
bcostm 0:44f624c5501e 5
bcostm 0:44f624c5501e 6 DigitalOut led1(LED1);
bcostm 0:44f624c5501e 7
bcostm 0:44f624c5501e 8 int main()
bcostm 0:44f624c5501e 9 {
bcostm 0:44f624c5501e 10 float GyroBuffer[3];
bcostm 0:44f624c5501e 11
bcostm 0:44f624c5501e 12 printf("Gyroscope started\n");
bcostm 0:44f624c5501e 13
bcostm 0:44f624c5501e 14 while(1) {
bcostm 0:44f624c5501e 15 // Read Gyroscope values
bcostm 0:44f624c5501e 16 gyro.GetXYZ(GyroBuffer);
bcostm 0:44f624c5501e 17 // Display values
bcostm 0:44f624c5501e 18 printf("X = %f\n", GyroBuffer[0]);
bcostm 0:44f624c5501e 19 printf("Y = %f\n", GyroBuffer[1]);
bcostm 0:44f624c5501e 20 printf("Z = %f\n", GyroBuffer[2]);
bcostm 0:44f624c5501e 21 printf("\033[3A"); // Moves cursor up x lines (x value is between [ and A)
bcostm 0:44f624c5501e 22 led1 = !led1;
bcostm 0:44f624c5501e 23 wait(1);
bcostm 0:44f624c5501e 24 }
bcostm 0:44f624c5501e 25 }