![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
VMA306 Library HelloWorld program
main.cpp@1:dde51c1d6477, 2018-06-01 (annotated)
- Committer:
- haarkon
- Date:
- Fri Jun 01 07:29:32 2018 +0000
- Revision:
- 1:dde51c1d6477
- Parent:
- 0:9afd9068bcc9
Reshape and added comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
haarkon | 0:9afd9068bcc9 | 1 | #include "mbed.h" |
haarkon | 1:dde51c1d6477 | 2 | #include "VMA306.h" |
haarkon | 0:9afd9068bcc9 | 3 | |
haarkon | 1:dde51c1d6477 | 4 | Serial pc (PA_2, PA_3, 921600); // Create a serial link to PC for communication |
haarkon | 0:9afd9068bcc9 | 5 | |
haarkon | 1:dde51c1d6477 | 6 | VMA306 UltraSon (PB_15, PA_6, PB_14, PC_7, PB_13, PB_2); // Create 3 ultrasonic sensors (1 and 2 sensor support will be added) |
haarkon | 0:9afd9068bcc9 | 7 | |
haarkon | 1:dde51c1d6477 | 8 | DigitalOut led1 (PA_5); // Added Led1 for test purpose |
haarkon | 1:dde51c1d6477 | 9 | DigitalOut led2 (PD_2); // Added Led2 for test purpose |
haarkon | 1:dde51c1d6477 | 10 | DigitalOut disquette (PA_12); // Added baloon destructor command (without it, you might see baloon destructor motor be set to full speed) |
haarkon | 0:9afd9068bcc9 | 11 | |
haarkon | 0:9afd9068bcc9 | 12 | int main() |
haarkon | 0:9afd9068bcc9 | 13 | { |
haarkon | 1:dde51c1d6477 | 14 | led1 = 1; // Led1 switch ON |
haarkon | 1:dde51c1d6477 | 15 | led2 = 0; // Led2 switch OFF |
haarkon | 1:dde51c1d6477 | 16 | disquette = 0; // Baloon destructor switch OFF |
haarkon | 0:9afd9068bcc9 | 17 | |
haarkon | 0:9afd9068bcc9 | 18 | while(1) { |
haarkon | 1:dde51c1d6477 | 19 | if (UltraSon.isUSGReady()) pc.printf ("\rusG = %5.2lf -", UltraSon.readUSG()); // If left ultra sonic seonsor has a mesurment print it |
haarkon | 1:dde51c1d6477 | 20 | else pc.printf ("\r -"); // Else delete previous display of USG value |
haarkon | 1:dde51c1d6477 | 21 | if (UltraSon.isUSBReady()) pc.printf ("\r\t\t usB = %5.2lf -", UltraSon.readUSB()); // If back ultra sonic seonsor has a mesurment print it |
haarkon | 1:dde51c1d6477 | 22 | else pc.printf ("\r\t\t -"); // Else delete previous display of USB value |
haarkon | 1:dde51c1d6477 | 23 | if (UltraSon.isUSDReady()) pc.printf ("\r\t\t\t\t usD = %5.2lf", UltraSon.readUSD()); // If right ultra sonic seonsor has a mesurment print it |
haarkon | 1:dde51c1d6477 | 24 | else pc.printf ("\r\t\t\t\t "); // Else delete previous display of USB value |
haarkon | 1:dde51c1d6477 | 25 | |
haarkon | 1:dde51c1d6477 | 26 | led1 = !led1; // Switch Led1 |
haarkon | 1:dde51c1d6477 | 27 | led2 = !led2; // Switch Led2 |
haarkon | 0:9afd9068bcc9 | 28 | } |
haarkon | 0:9afd9068bcc9 | 29 | } |