![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
55+
Dependencies: BEAR_Protocol_Edited BufferedSerial Debug MaxSonar PID Process QEI UI iSerial mbed
Fork of CleaningMachine_Betago by
UNTRASONIC.cpp@3:edaab92dbd2f, 2016-05-24 (annotated)
- Committer:
- palmdotax
- Date:
- Tue May 24 10:33:21 2016 +0000
- Revision:
- 3:edaab92dbd2f
- Parent:
- 1:45f1573d65a1
55+
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
palmdotax | 1:45f1573d65a1 | 1 | #include "mbed.h" |
palmdotax | 1:45f1573d65a1 | 2 | #include "MaxSonar.h" |
palmdotax | 1:45f1573d65a1 | 3 | #include "UNTRASONIC.h" |
palmdotax | 1:45f1573d65a1 | 4 | MaxSonar *range1; |
palmdotax | 1:45f1573d65a1 | 5 | MaxSonar *range2; |
palmdotax | 1:45f1573d65a1 | 6 | MaxSonar *range3; |
palmdotax | 1:45f1573d65a1 | 7 | MaxSonar *range4; |
palmdotax | 1:45f1573d65a1 | 8 | MaxSonar *range5; |
palmdotax | 1:45f1573d65a1 | 9 | MaxSonar *range6; |
palmdotax | 1:45f1573d65a1 | 10 | MaxSonar *range7; |
palmdotax | 1:45f1573d65a1 | 11 | MaxSonar *range8; |
palmdotax | 1:45f1573d65a1 | 12 | MaxSonar *range9; |
palmdotax | 1:45f1573d65a1 | 13 | MaxSonar *range10; |
palmdotax | 1:45f1573d65a1 | 14 | sensor::sensor() |
palmdotax | 1:45f1573d65a1 | 15 | { |
palmdotax | 1:45f1573d65a1 | 16 | sen_1=0; |
palmdotax | 1:45f1573d65a1 | 17 | sen_2=0; |
palmdotax | 1:45f1573d65a1 | 18 | sen_3=0; |
palmdotax | 1:45f1573d65a1 | 19 | sen_4=0; |
palmdotax | 1:45f1573d65a1 | 20 | sen_5=0; |
palmdotax | 1:45f1573d65a1 | 21 | sen_6=0; |
palmdotax | 1:45f1573d65a1 | 22 | sen_7=0; |
palmdotax | 1:45f1573d65a1 | 23 | sen_8=0; |
palmdotax | 1:45f1573d65a1 | 24 | sen_9=0; |
palmdotax | 1:45f1573d65a1 | 25 | sen_10=0; |
palmdotax | 1:45f1573d65a1 | 26 | |
palmdotax | 1:45f1573d65a1 | 27 | |
palmdotax | 1:45f1573d65a1 | 28 | } |
palmdotax | 1:45f1573d65a1 | 29 | void sensor::get_sen() |
palmdotax | 1:45f1573d65a1 | 30 | { |
palmdotax | 1:45f1573d65a1 | 31 | range1->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 32 | sen_1 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 33 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 34 | range2->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 35 | sen_2 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 36 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 37 | range3->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 38 | sen_3 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 39 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 40 | range4->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 41 | sen_4 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 42 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 43 | range5->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 44 | sen_5 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 45 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 46 | range6->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 47 | sen_6 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 48 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 49 | range7->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 50 | sen_7 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 51 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 52 | range8->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 53 | sen_8 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 54 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 55 | range9->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 56 | sen_9 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 57 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 58 | range10->triggerRead(); |
palmdotax | 1:45f1573d65a1 | 59 | sen_10 = range1->read(); |
palmdotax | 1:45f1573d65a1 | 60 | //ส่งค่sensor |
palmdotax | 1:45f1573d65a1 | 61 | } |
palmdotax | 1:45f1573d65a1 | 62 | void sensor::inti() |
palmdotax | 1:45f1573d65a1 | 63 | { |
palmdotax | 1:45f1573d65a1 | 64 | //MaxSonar *range1; |
palmdotax | 1:45f1573d65a1 | 65 | range1 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_0); |
palmdotax | 1:45f1573d65a1 | 66 | range1->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 67 | range1->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 68 | |
palmdotax | 1:45f1573d65a1 | 69 | //MaxSonar *range2; |
palmdotax | 1:45f1573d65a1 | 70 | range2 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_1); |
palmdotax | 1:45f1573d65a1 | 71 | range2->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 72 | range2->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 73 | |
palmdotax | 1:45f1573d65a1 | 74 | // MaxSonar *range3; |
palmdotax | 1:45f1573d65a1 | 75 | range3 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_4); |
palmdotax | 1:45f1573d65a1 | 76 | range3->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 77 | range3->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 78 | |
palmdotax | 1:45f1573d65a1 | 79 | //MaxSonar *range4; |
palmdotax | 1:45f1573d65a1 | 80 | range4 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PB_0); |
palmdotax | 1:45f1573d65a1 | 81 | range4->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 82 | range4->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 83 | |
palmdotax | 1:45f1573d65a1 | 84 | //MaxSonar *range5; |
palmdotax | 1:45f1573d65a1 | 85 | range5 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_1); |
palmdotax | 1:45f1573d65a1 | 86 | range5->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 87 | range5->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 88 | |
palmdotax | 1:45f1573d65a1 | 89 | // MaxSonar *range6; |
palmdotax | 1:45f1573d65a1 | 90 | range6 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_0); |
palmdotax | 1:45f1573d65a1 | 91 | range6->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 92 | range6->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 93 | |
palmdotax | 1:45f1573d65a1 | 94 | //MaxSonar *range7; |
palmdotax | 1:45f1573d65a1 | 95 | range7 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_2); |
palmdotax | 1:45f1573d65a1 | 96 | range7->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 97 | range7->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 98 | |
palmdotax | 1:45f1573d65a1 | 99 | // MaxSonar *range8; |
palmdotax | 1:45f1573d65a1 | 100 | range8 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_3); |
palmdotax | 1:45f1573d65a1 | 101 | range8->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 102 | range8->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 103 | |
palmdotax | 1:45f1573d65a1 | 104 | // MaxSonar *range9; |
palmdotax | 1:45f1573d65a1 | 105 | range9 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_4); |
palmdotax | 1:45f1573d65a1 | 106 | range9->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 107 | range9->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 108 | |
palmdotax | 1:45f1573d65a1 | 109 | // MaxSonar *range10; |
palmdotax | 1:45f1573d65a1 | 110 | range10 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_5); |
palmdotax | 1:45f1573d65a1 | 111 | range10->setVoltage(3.3); |
palmdotax | 1:45f1573d65a1 | 112 | range10->setUnits(MS_CM); |
palmdotax | 1:45f1573d65a1 | 113 | } |
palmdotax | 1:45f1573d65a1 | 114 | void sensor::readbat() |
palmdotax | 1:45f1573d65a1 | 115 | { |
palmdotax | 1:45f1573d65a1 | 116 | |
palmdotax | 1:45f1573d65a1 | 117 | } |