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
Revision 3:3d53799c2f18, committed 2015-03-07
- Comitter:
- Ali_taher
- Date:
- Sat Mar 07 22:56:18 2015 +0000
- Parent:
- 2:b109a4eb9b0d
- Child:
- 4:70090f3b1f07
- Commit message:
- reading from serial port ; each number separated by carriage return is assigned to one variable
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Mar 05 17:43:10 2015 +0000 +++ b/main.cpp Sat Mar 07 22:56:18 2015 +0000 @@ -10,8 +10,8 @@ // Globel variables char cordinates[20]; -char corHoriz; -char corVertic; +char corHoriz[20]; +char corVertic[20]; //float corDeep; //float outVert; //float outHoriz; @@ -24,7 +24,9 @@ mutexIn.lock(); // pc.gets(cordinates,4); // cordinates = pc.putc(pc.getc()); - pc.gets(cordinates,4);// read from serial port the data + pc.scanf("%s \n %s \n %s",cordinates,corHoriz,corVertic);// read from serial port the data + // look for carriage return and assign the first number of to the cordinates and then the second to corHiz + //corHoriz=cordinates; // corHoriz=(cordinates[0]+cordinates[1]+cordinates[2]+cordinates[3]); // corVertic=(cordinates[4]+cordinates[5]+cordinates[6]+cordinates[7]); @@ -45,7 +47,11 @@ // Display values on the LCD screen lcd.cls(); // clear the display lcd.locate(0,3); // the location where you want your charater to be displayed - lcd.printf("Hor: %s ",cordinates ); + lcd.printf("Hor:%s",cordinates); + lcd.locate(0,10); // the location where you want your charater to be displayed + lcd.printf("Ver%s", corHoriz); + lcd.locate(0,20); // the location where you want your charater to be displayed + lcd.printf("Ver%s", corVertic); // lcd.printf("vertical: %s ",cordinates ); mutexIn.unlock(); mutexOut.unlock();