![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
3Axis gyro sensor sample. target sensor: L3GD20(ST)
main.cpp@0:a1d1374eea97, 2018-12-17 (annotated)
- Committer:
- satoshi1204
- Date:
- Mon Dec 17 12:47:04 2018 +0000
- Revision:
- 0:a1d1374eea97
Implementation sample program for gyro sensor L3GD20
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
satoshi1204 | 0:a1d1374eea97 | 1 | #include "mbed.h" |
satoshi1204 | 0:a1d1374eea97 | 2 | #include "L3GD20.h" |
satoshi1204 | 0:a1d1374eea97 | 3 | |
satoshi1204 | 0:a1d1374eea97 | 4 | DigitalOut myled(LED1); |
satoshi1204 | 0:a1d1374eea97 | 5 | Serial pc(USBTX, USBRX); |
satoshi1204 | 0:a1d1374eea97 | 6 | L3GD20 gyro(p9, p10); |
satoshi1204 | 0:a1d1374eea97 | 7 | |
satoshi1204 | 0:a1d1374eea97 | 8 | int main() { |
satoshi1204 | 0:a1d1374eea97 | 9 | while(1) { |
satoshi1204 | 0:a1d1374eea97 | 10 | myled = 1; |
satoshi1204 | 0:a1d1374eea97 | 11 | wait(0.2); |
satoshi1204 | 0:a1d1374eea97 | 12 | double x, y, z; |
satoshi1204 | 0:a1d1374eea97 | 13 | gyro.readData(x, y, z); |
satoshi1204 | 0:a1d1374eea97 | 14 | pc.printf("%5.4lf %5.4lf %5.4lf\r\n", x, y, z); |
satoshi1204 | 0:a1d1374eea97 | 15 | myled = 0; |
satoshi1204 | 0:a1d1374eea97 | 16 | wait(0.2); |
satoshi1204 | 0:a1d1374eea97 | 17 | } |
satoshi1204 | 0:a1d1374eea97 | 18 | } |