![](/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
Diff: UNTRASONIC.cpp
- Revision:
- 1:45f1573d65a1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UNTRASONIC.cpp Mon Mar 21 20:21:12 2016 +0000 @@ -0,0 +1,117 @@ +#include "mbed.h" +#include "MaxSonar.h" +#include "UNTRASONIC.h" +MaxSonar *range1; +MaxSonar *range2; +MaxSonar *range3; +MaxSonar *range4; +MaxSonar *range5; +MaxSonar *range6; +MaxSonar *range7; +MaxSonar *range8; +MaxSonar *range9; +MaxSonar *range10; +sensor::sensor() +{ + sen_1=0; + sen_2=0; + sen_3=0; + sen_4=0; + sen_5=0; + sen_6=0; + sen_7=0; + sen_8=0; + sen_9=0; + sen_10=0; + + +} +void sensor::get_sen() +{ + range1->triggerRead(); + sen_1 = range1->read(); + //ส่งค่sensor + range2->triggerRead(); + sen_2 = range1->read(); + //ส่งค่sensor + range3->triggerRead(); + sen_3 = range1->read(); + //ส่งค่sensor + range4->triggerRead(); + sen_4 = range1->read(); + //ส่งค่sensor + range5->triggerRead(); + sen_5 = range1->read(); + //ส่งค่sensor + range6->triggerRead(); + sen_6 = range1->read(); + //ส่งค่sensor + range7->triggerRead(); + sen_7 = range1->read(); + //ส่งค่sensor + range8->triggerRead(); + sen_8 = range1->read(); + //ส่งค่sensor + range9->triggerRead(); + sen_9 = range1->read(); + //ส่งค่sensor + range10->triggerRead(); + sen_10 = range1->read(); + //ส่งค่sensor +} +void sensor::inti() +{ + //MaxSonar *range1; + range1 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_0); + range1->setVoltage(3.3); + range1->setUnits(MS_CM); + + //MaxSonar *range2; + range2 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_1); + range2->setVoltage(3.3); + range2->setUnits(MS_CM); + + // MaxSonar *range3; + range3 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PA_4); + range3->setVoltage(3.3); + range3->setUnits(MS_CM); + + //MaxSonar *range4; + range4 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PB_0); + range4->setVoltage(3.3); + range4->setUnits(MS_CM); + + //MaxSonar *range5; + range5 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_1); + range5->setVoltage(3.3); + range5->setUnits(MS_CM); + + // MaxSonar *range6; + range6 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_0); + range6->setVoltage(3.3); + range6->setUnits(MS_CM); + + //MaxSonar *range7; + range7 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_2); + range7->setVoltage(3.3); + range7->setUnits(MS_CM); + + // MaxSonar *range8; + range8 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_3); + range8->setVoltage(3.3); + range8->setUnits(MS_CM); + + // MaxSonar *range9; + range9 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_4); + range9->setVoltage(3.3); + range9->setUnits(MS_CM); + + // MaxSonar *range10; + range10 = new MaxSonar(MS_LV, MS_ANALOG, PC_7, PC_5); + range10->setVoltage(3.3); + range10->setUnits(MS_CM); +} +void sensor::readbat() +{ + +} \ No newline at end of file