Version1
Dependencies: MP3_TF_16P mbed
main.cpp@0:3bcb41e0da86, 2022-01-25 (annotated)
- Committer:
- JeroenAero
- Date:
- Tue Jan 25 19:26:40 2022 +0000
- Revision:
- 0:3bcb41e0da86
Version1;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JeroenAero | 0:3bcb41e0da86 | 1 | #include "mbed.h" |
JeroenAero | 0:3bcb41e0da86 | 2 | #include "LAS_TB.h" |
JeroenAero | 0:3bcb41e0da86 | 3 | |
JeroenAero | 0:3bcb41e0da86 | 4 | Serial pc(USBTX, USBRX); // tx, rx |
JeroenAero | 0:3bcb41e0da86 | 5 | |
JeroenAero | 0:3bcb41e0da86 | 6 | //initialize mp3 player. |
JeroenAero | 0:3bcb41e0da86 | 7 | LAS_TB LaserSensor(D1,D0); |
JeroenAero | 0:3bcb41e0da86 | 8 | |
JeroenAero | 0:3bcb41e0da86 | 9 | DigitalOut TeKlein(D6); |
JeroenAero | 0:3bcb41e0da86 | 10 | DigitalOut Goed(D7); |
JeroenAero | 0:3bcb41e0da86 | 11 | DigitalOut TeGroot(D8); |
JeroenAero | 0:3bcb41e0da86 | 12 | |
JeroenAero | 0:3bcb41e0da86 | 13 | double millimeters = 0; |
JeroenAero | 0:3bcb41e0da86 | 14 | |
JeroenAero | 0:3bcb41e0da86 | 15 | int main() |
JeroenAero | 0:3bcb41e0da86 | 16 | { |
JeroenAero | 0:3bcb41e0da86 | 17 | |
JeroenAero | 0:3bcb41e0da86 | 18 | pc.baud(9600); |
JeroenAero | 0:3bcb41e0da86 | 19 | |
JeroenAero | 0:3bcb41e0da86 | 20 | pc.printf("Opstarten!\r\n"); |
JeroenAero | 0:3bcb41e0da86 | 21 | |
JeroenAero | 0:3bcb41e0da86 | 22 | wait(1); |
JeroenAero | 0:3bcb41e0da86 | 23 | |
JeroenAero | 0:3bcb41e0da86 | 24 | while(1) |
JeroenAero | 0:3bcb41e0da86 | 25 | { |
JeroenAero | 0:3bcb41e0da86 | 26 | wait(2); //Om de 2 seconden uitvoeren. |
JeroenAero | 0:3bcb41e0da86 | 27 | |
JeroenAero | 0:3bcb41e0da86 | 28 | LaserSensor.MeasurementRequest(); |
JeroenAero | 0:3bcb41e0da86 | 29 | wait(0.5); //Halve sec wachten tot meting binnen is. |
JeroenAero | 0:3bcb41e0da86 | 30 | |
JeroenAero | 0:3bcb41e0da86 | 31 | //uitlezen. |
JeroenAero | 0:3bcb41e0da86 | 32 | millimeters = (double)LaserSensor.umvalue/1000.0f; |
JeroenAero | 0:3bcb41e0da86 | 33 | |
JeroenAero | 0:3bcb41e0da86 | 34 | pc.printf("millimeters: %f\r\n", millimeters); |
JeroenAero | 0:3bcb41e0da86 | 35 | |
JeroenAero | 0:3bcb41e0da86 | 36 | if (millimeters < 49.95f) |
JeroenAero | 0:3bcb41e0da86 | 37 | { |
JeroenAero | 0:3bcb41e0da86 | 38 | TeKlein = true; |
JeroenAero | 0:3bcb41e0da86 | 39 | Goed = false; |
JeroenAero | 0:3bcb41e0da86 | 40 | TeGroot = false; |
JeroenAero | 0:3bcb41e0da86 | 41 | pc.printf("Te klein!\r\n"); |
JeroenAero | 0:3bcb41e0da86 | 42 | } |
JeroenAero | 0:3bcb41e0da86 | 43 | else if (millimeters > 51.05f) |
JeroenAero | 0:3bcb41e0da86 | 44 | { |
JeroenAero | 0:3bcb41e0da86 | 45 | TeKlein = false; |
JeroenAero | 0:3bcb41e0da86 | 46 | Goed = false; |
JeroenAero | 0:3bcb41e0da86 | 47 | TeGroot = true; |
JeroenAero | 0:3bcb41e0da86 | 48 | pc.printf("Te groot!\r\n"); |
JeroenAero | 0:3bcb41e0da86 | 49 | } |
JeroenAero | 0:3bcb41e0da86 | 50 | else |
JeroenAero | 0:3bcb41e0da86 | 51 | { |
JeroenAero | 0:3bcb41e0da86 | 52 | TeKlein = false; |
JeroenAero | 0:3bcb41e0da86 | 53 | Goed = true; |
JeroenAero | 0:3bcb41e0da86 | 54 | TeGroot = false; |
JeroenAero | 0:3bcb41e0da86 | 55 | pc.printf("Goed!\r\n"); |
JeroenAero | 0:3bcb41e0da86 | 56 | } |
JeroenAero | 0:3bcb41e0da86 | 57 | } |
JeroenAero | 0:3bcb41e0da86 | 58 | } |