gyro
Dependencies: BSP_DISCO_F429ZI GYRO_DISCO_F429ZI LCD_DISCO_F429ZI mbed
Fork of DISCO-F429ZI_Gyro_demo by
main.cpp@0:44f624c5501e, 2015-12-18 (annotated)
- Committer:
- bcostm
- Date:
- Fri Dec 18 14:39:20 2015 +0000
- Revision:
- 0:44f624c5501e
- Child:
- 2:b878d61bf57b
Initial version
Who changed what in which revision?
User | Revision | Line number | New 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 | } |