![](/media/cache/profiles/da2c9b4ce3910da210c419517ee72bf0.jpg.50x50_q85.jpg)
Demo Program for the Parallax X-Band Motion detector.
Dependencies: Parallax_X-Band mbed
main.cpp@0:207fde6d4312, 2015-03-08 (annotated)
- Committer:
- ottaviano3
- Date:
- Sun Mar 08 20:03:06 2015 +0000
- Revision:
- 0:207fde6d4312
- Child:
- 1:f03e66b92d1d
Demo program for the Parallax X-Band Motion Detector.
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 | 0:207fde6d4312 | 12 | |
ottaviano3 | 0:207fde6d4312 | 13 | while(1) { |
ottaviano3 | 0:207fde6d4312 | 14 | // Wait for a new velocity value to be calculated. |
ottaviano3 | 0:207fde6d4312 | 15 | while (myxband.velocityack() == true) { |
ottaviano3 | 0:207fde6d4312 | 16 | // Once a new one is avaliable print it to the USB serial port. |
ottaviano3 | 0:207fde6d4312 | 17 | pc.printf("Velocity: %f Ticks/sec\n\r",myxband.read_velocity()); |
ottaviano3 | 0:207fde6d4312 | 18 | } |
ottaviano3 | 0:207fde6d4312 | 19 | } |
ottaviano3 | 0:207fde6d4312 | 20 | } |