sonar sensor is working in the version of code but the reading are not correct
Dependencies: C12832 Pulse RangeFinder Servo mbed rtos
Fork of Team_Sprint2 by
Diff: main.cpp
- Revision:
- 24:00a577f64930
- Parent:
- 23:f098ffcd192a
--- a/main.cpp Thu Apr 23 10:50:12 2015 +0000 +++ b/main.cpp Thu Apr 23 11:00:40 2015 +0000 @@ -6,15 +6,13 @@ Servo tiltServo(p24); Servo panServo(p25); +Servo vertServo(p23); Serial pc(USBTX, USBRX); -Servo vertServo(p23); Mutex mutexIn;// protect global variables Mutex mutexOut;// protect global variables Mutex mutex_sonar; -AnalogIn sonar(p19); // temporary changed to potmeter -AnalogIn corVert(p20); // temporary changed to potmeter -Mutex mutexIn; -Mutex mutexOut; +AnalogIn sonar(p17); // correct is p17. TEMPORARY changed to potmeter p19 +//AnalogIn corVert(p20); // TO REMOVE. Temporary changed to potmeter // Global variables float corHoriz = 0.5; // horizontal variable arrives from OpenCV @@ -38,7 +36,7 @@ void serial_thread(void const *args) { while (true) { - pc.scanf("%f,%f", &corHoriz, &corVert1);// read from serial port the data // temporary Vert1 + pc.scanf("%f,%f", &corHoriz, &corVert);// read from serial port the data // temporary Vert1 } } @@ -53,7 +51,7 @@ lcd.locate(0,1); // the location where you want your charater to be displayed lcd.printf("Sonar: %0.3f, OutTilt: %0.3f", sonar.read(), outTilt); lcd.locate(0,9); // the location where you want your charater to be displayed - lcd.printf("Vert: %0.3f, OutVert: %0.3f", corVert.read(), outVert); + lcd.printf("Vert: %0.3f, OutVert: %0.3f", corVert, outVert); Thread::wait(250); } }