John Curran
/
mbed_Lab3_Digital_sensorsandequations_in_C_JohnCurranT00214119
Lab 3ES_ John Curran T00214119
main.cpp@3:7380a26ac26f, 2021-04-17 (annotated)
- Committer:
- johnc89
- Date:
- Sat Apr 17 15:48:16 2021 +0000
- Revision:
- 3:7380a26ac26f
- Parent:
- 0:bd0546063b0a
- Child:
- 4:efd9328bb9f0
First test carried out
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 0:bd0546063b0a | 1 | //Uses the measured z-acceleration to drive leds 2 and 3 of the mbed |
Sissors | 0:bd0546063b0a | 2 | |
Sissors | 0:bd0546063b0a | 3 | #include "mbed.h" |
Sissors | 0:bd0546063b0a | 4 | #include "MMA7660.h" |
johnc89 | 3:7380a26ac26f | 5 | Serial pc(USBTX,USBRX);// serial communications |
Sissors | 0:bd0546063b0a | 6 | MMA7660 MMA(p28, p27); |
Sissors | 0:bd0546063b0a | 7 | |
Sissors | 0:bd0546063b0a | 8 | DigitalOut connectionLed(LED1); |
Sissors | 0:bd0546063b0a | 9 | PwmOut Zaxis_p(LED2); |
Sissors | 0:bd0546063b0a | 10 | PwmOut Zaxis_n(LED3); |
Sissors | 0:bd0546063b0a | 11 | |
Sissors | 0:bd0546063b0a | 12 | int main() { |
Sissors | 0:bd0546063b0a | 13 | if (MMA.testConnection()) |
Sissors | 0:bd0546063b0a | 14 | connectionLed = 1; |
Sissors | 0:bd0546063b0a | 15 | |
Sissors | 0:bd0546063b0a | 16 | while(1) { |
johnc89 | 3:7380a26ac26f | 17 | pc.printf ("%f, %f, %f \r\n", MMA.x(), MMA.y(), MMA.z() ); |
johnc89 | 3:7380a26ac26f | 18 | wait (0.5); |
Sissors | 0:bd0546063b0a | 19 | } |
Sissors | 0:bd0546063b0a | 20 | |
Sissors | 0:bd0546063b0a | 21 | } |