h
Dependencies: MMA7660 USBDevice mbed
Fork of lecture2_demo2 by
main.cpp@8:d79a78d6b922, 2015-11-19 (annotated)
- Committer:
- co657_mh560
- Date:
- Thu Nov 19 12:12:13 2015 +0000
- Revision:
- 8:d79a78d6b922
- Parent:
- 7:23de08e003ec
hello
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 1:291a88a2c151 | 1 | #include "mbed.h" |
co657_mh560 | 8:d79a78d6b922 | 2 | |
colingj | 7:23de08e003ec | 3 | #include "MMA7660.h" /* for the accelerometer */ |
colingj | 7:23de08e003ec | 4 | |
co657_mh560 | 8:d79a78d6b922 | 5 | |
colingj | 7:23de08e003ec | 6 | MMA7660 MMA(D14, D15); /* accelerometer */ |
co657_mh560 | 8:d79a78d6b922 | 7 | Serial xbee (D1, D0); |
colingj | 7:23de08e003ec | 8 | |
colingj | 7:23de08e003ec | 9 | int main(void) |
colingj | 7:23de08e003ec | 10 | { |
colingj | 7:23de08e003ec | 11 | float x,y,countdown; |
co657_mh560 | 8:d79a78d6b922 | 12 | |
colingj | 7:23de08e003ec | 13 | countdown = 0.0; |
samux | 1:291a88a2c151 | 14 | while (1) { |
colingj | 7:23de08e003ec | 15 | x = MMA.x(); |
colingj | 7:23de08e003ec | 16 | y = MMA.y(); |
co657_mh560 | 8:d79a78d6b922 | 17 | if (y>0.6f) |
co657_mh560 | 8:d79a78d6b922 | 18 | { |
co657_mh560 | 8:d79a78d6b922 | 19 | xbee.printf("d"); |
co657_mh560 | 8:d79a78d6b922 | 20 | } |
co657_mh560 | 8:d79a78d6b922 | 21 | if (y<-0.6f) |
co657_mh560 | 8:d79a78d6b922 | 22 | { |
co657_mh560 | 8:d79a78d6b922 | 23 | xbee.printf("u"); |
co657_mh560 | 8:d79a78d6b922 | 24 | } |
co657_mh560 | 8:d79a78d6b922 | 25 | if ((abs(x)>0.6f)&&(countdown<=0.0f)) |
co657_mh560 | 8:d79a78d6b922 | 26 | { |
co657_mh560 | 8:d79a78d6b922 | 27 | |
co657_mh560 | 8:d79a78d6b922 | 28 | xbee.printf("p"); |
colingj | 7:23de08e003ec | 29 | countdown = 10.0f; |
co657_mh560 | 8:d79a78d6b922 | 30 | |
colingj | 7:23de08e003ec | 31 | } |
colingj | 7:23de08e003ec | 32 | countdown -= 1.0f; |
colingj | 7:23de08e003ec | 33 | wait (0.1); |
co657_mh560 | 8:d79a78d6b922 | 34 | |
samux | 1:291a88a2c151 | 35 | } |
samux | 4:f0df6aae7147 | 36 | } |