/*############################################################# Program Name : ex1_F429ZI_L3GD20 Author : Grant Phillips Date Modified : 18/09/2016 Compiler : ARMmbed Tested On : STM32F429ZI-Discovery Description : Example program that demonstrates the use of the L3GD20 3-axis digital gyroscope on the STM32F429ZI-Discovery. Requirements : * STM32F429ZI-Discovery Board Circuit : * NONE ##############################################################*/ #include "mbed.h" #include "LCD_DISCO_F429ZI.h" #include "GYRO_DISCO_F429ZI.h" LCD_DISCO_F429ZI lcd; //Create a LCD_DISCO_F429ZI object GYRO_DISCO_F429ZI gyro; //Create a GYRO_DISCO_F429ZI object to access the L3GD20 gyroscope DigitalOut led1(PG_13); int main() { float GyroBuffer[3]; //array to store the results for X, Y and Z from the gyro char buf[20]; //temporary string variable lcd.SetFont(&Font16); lcd.DisplayStringAtLine(1, (uint8_t *) "Gyroscope started"); while(1) { // Read Gyroscope values gyro.GetXYZ(GyroBuffer); // Display values sprintf(buf, "X = %14.3f", GyroBuffer[0]); lcd.DisplayStringAtLine(2,(uint8_t *) buf); sprintf(buf, "Y = %14.3f", GyroBuffer[1]); lcd.DisplayStringAtLine(3,(uint8_t *) buf); sprintf(buf, "Z = %14.3f", GyroBuffer[2]); lcd.DisplayStringAtLine(4,(uint8_t *) buf); led1 = !led1; //toggle led to show program is running wait(0.1); //delay before reading next gyro values } }