Demo Program for the Parallax X-Band Motion detector.
Dependencies: Parallax_X-Band mbed
main.cpp@1:f03e66b92d1d, 2015-03-09 (annotated)
- Committer:
- ottaviano3
- Date:
- Mon Mar 09 20:16:18 2015 +0000
- Revision:
- 1:f03e66b92d1d
- Parent:
- 0:207fde6d4312
Updated parallax library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ottaviano3 | 0:207fde6d4312 | 1 | #include "mbed.h" |
ottaviano3 | 0:207fde6d4312 | 2 | #include "Parallax_X-Band.h" |
ottaviano3 | 0:207fde6d4312 | 3 | |
ottaviano3 | 0:207fde6d4312 | 4 | Serial pc(USBTX, USBRX); |
ottaviano3 | 0:207fde6d4312 | 5 | |
ottaviano3 | 0:207fde6d4312 | 6 | xband myxband(p26, p25); |
ottaviano3 | 0:207fde6d4312 | 7 | |
ottaviano3 | 0:207fde6d4312 | 8 | int main() |
ottaviano3 | 0:207fde6d4312 | 9 | { |
ottaviano3 | 0:207fde6d4312 | 10 | // Enable the motion detector. |
ottaviano3 | 0:207fde6d4312 | 11 | myxband.enable(true); |
ottaviano3 | 1:f03e66b92d1d | 12 | |
ottaviano3 | 1:f03e66b92d1d | 13 | // Variable to store read velocity. |
ottaviano3 | 1:f03e66b92d1d | 14 | float velocity; |
ottaviano3 | 0:207fde6d4312 | 15 | |
ottaviano3 | 0:207fde6d4312 | 16 | while(1) { |
ottaviano3 | 0:207fde6d4312 | 17 | // Wait for a new velocity value to be calculated. |
ottaviano3 | 0:207fde6d4312 | 18 | while (myxband.velocityack() == true) { |
ottaviano3 | 0:207fde6d4312 | 19 | // Once a new one is avaliable print it to the USB serial port. |
ottaviano3 | 1:f03e66b92d1d | 20 | velocity = myxband; |
ottaviano3 | 1:f03e66b92d1d | 21 | pc.printf("Velocity: %f Ticks/sec\n\r",velocity); |
ottaviano3 | 0:207fde6d4312 | 22 | } |
ottaviano3 | 0:207fde6d4312 | 23 | } |
ottaviano3 | 0:207fde6d4312 | 24 | } |