Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE HC_SR04_Ultrasonic_Library mbed
main.cpp
00001 #include "mbed.h" 00002 #include "ultrasonic.h" 00003 #include "uLCD_4DGL.h"//uLCD class 00004 //BusOut myled(LED1,LED2,LED3,LED4); 00005 DigitalOut led1(LED1); 00006 DigitalOut led2(LED2); 00007 DigitalOut led3(LED3); 00008 DigitalOut led4(LED4); 00009 00010 //uLCD_4DGL uLCD(p9, p10, p7); // tx rx reset create a global lcd object 00011 00012 00013 Serial blue(p28,p27);//tx rx for bluetooth 00014 00015 Serial uart(p9,p10);//Sungwoo 00016 00017 00018 //////////////////////////////////////////////// 00019 00020 volatile int distan0 = 0;//front 00021 volatile int distan1 = 0;//left 00022 volatile int distan2r = 0;//back right 00023 volatile int distan2l = 0;//back left 00024 volatile int distan3 = 0;//right 00025 volatile int distan1b = 0;//left2 00026 volatile int distan3b = 0;//right2 00027 00028 //volatile char s[1]; 00029 00030 void dist0(int distance0) 00031 { 00032 //put code here to execute when the distance has changed 00033 //uLCD.locate(0,1); 00034 //uLCD.printf("DistanceFront %d \r\n", distance0); 00035 distan0 = distance0; 00036 } 00037 void dist1(int distance1) 00038 { 00039 //uLCD.locate(0,3); 00040 //uLCD.printf("DistanceLeft %d \r\n", distance1); 00041 distan1 = distance1; 00042 } 00043 00044 void dist1b(int distance1b) 00045 { 00046 //uLCD.locate(0,5); 00047 //uLCD.printf("DistanceLeftB %d \r\n", distance1b); 00048 distan1b = distance1b; 00049 } 00050 void dist2r(int distance2r) 00051 { 00052 //uLCD.locate(0,7); 00053 //uLCD.printf("DisatnceBack %d \r\n", distance2); 00054 distan2r = distance2r; 00055 00056 } 00057 void dist2l(int distance2l) 00058 { 00059 distan2l = distance2l; 00060 } 00061 void dist3(int distance3) 00062 { 00063 //uLCD.locate(0,9); 00064 //uLCD.printf("DistanceRight %d \r\n", distance3); 00065 distan3 = distance3; 00066 } 00067 00068 void dist3b(int distance3b) 00069 { 00070 //uLCD.locate(0,11); 00071 //uLCD.printf("DistanceRightB %d \r\n", distance3b); 00072 distan3b = distance3b; 00073 } 00074 ultrasonic front(p8, p11, .1, .5, &dist0);//trig echo 00075 //have updates every .1 seconds and a timeout after 1 00076 //second, and call dist when the distance changes 00077 ultrasonic left1(p25, p26, .1, .5, &dist1); 00078 ultrasonic left2(p12, p13, .1, .5, &dist1b); 00079 ultrasonic backl(p21, p22, .1, .5, &dist2l); 00080 ultrasonic backr(p5, p6, .1, .5, &dist2r); 00081 ultrasonic right1(p29, p30, .1, .5, &dist3); 00082 ultrasonic right2(p23, p24, .1, .5, &dist3b); 00083 00084 /////////////////////////////////////////////// 00085 00086 int main() 00087 { 00088 char bnum=0; 00089 char bhit=0; 00090 00091 //Sungwoo 00092 uart.baud(9600); 00093 00094 char f = 'f'; // Move forward 00095 char b = 'b'; // Move Backward 00096 char l = 'l'; // Turn Left 00097 char r = 'r'; // Turn Right 00098 char w = 'w'; // Park on the left 00099 char x = 'x'; // Pakk on the right 00100 00101 char a = 'a'; // tilt to the left 00102 char z = 'z'; // tilt to the right 00103 char p = 'p'; // Parked 00104 00105 char g = 'g'; // tilt angle to the left (CCW) 00106 char h = 'h'; // tilt angle to the right (CW) 00107 00108 00109 //////////////////////////////// 00110 00111 //bool variables for each sensor 00112 bool fSensor = false; 00113 bool r1Sensor = false; 00114 bool r2Sensor = false; 00115 bool brSensor = false; 00116 bool blSensor = false; 00117 bool l1Sensor = false; 00118 bool l2Sensor = false; 00119 00120 00121 //char bnum=0; 00122 //char bhit=0; 00123 00124 00125 00126 //Front - 0, Left - 1, Back - 2, Right - 3 00127 int diffLR = 0; 00128 int diffLR2 = 0; 00129 //uLCD.printf("Hey"); 00130 00131 00132 ///////////////////////////////////// 00133 00134 while(1) { 00135 if (blue.getc()=='!') { 00136 if (blue.getc()=='B') { //button data packet 00137 bnum = blue.getc(); //button number 00138 bhit = blue.getc(); //1=hit, 0=release 00139 if (blue.getc()==char(~('!' + 'B' + bnum + bhit))) { //checksum OK? 00140 //myled = bnum - '0'; //current button number will appear on LEDs 00141 switch (bnum) { 00142 case '1': //number button 1 00143 00144 if (bhit=='1') 00145 { 00146 //uLCD.locate(0,1); 00147 //uLCD.printf("Parking start"); 00148 00149 //int distance = 0; 00150 front.startUpdates();//start measuring the distance 00151 left1.startUpdates(); 00152 left2.startUpdates(); 00153 backr.startUpdates(); 00154 backl.startUpdates(); 00155 right1.startUpdates(); 00156 right2.startUpdates(); 00157 00158 //////////////////////////parking #1//////////////////////////////// 00159 00160 00161 while(1) 00162 { 00163 //Do something else here 00164 front.checkDistance(); //call checkDistance() as much as possible, as this is where 00165 //the class checks if dist needs to be called. 00166 left1.checkDistance(); 00167 left2.checkDistance(); 00168 backr.checkDistance(); 00169 backl.checkDistance(); 00170 right1.checkDistance(); 00171 right2.checkDistance(); 00172 /*uLCD.locate(0,5); 00173 uLCD.printf("distance0: %d", distan0); 00174 uLCD.locate(0,6); 00175 uLCD.printf("distance1: %d", distan1);*/ 00176 00177 diffLR = abs(distan1 - distan3); 00178 diffLR2 = abs(distan1b - distan3b); 00179 // uLCD.locate(0,7); 00180 // uLCD.printf("diiference 12: %d", diffLR); 00181 00182 // #1 - check the front sensor 00183 if(distan0>300) 00184 { 00185 fSensor = true; 00186 //zig-zag feature in the map by adjusting the distance of left1 and right1 sensors 00187 00188 // 'a' - tilt to left. 00189 if((diffLR<100) && (distan1>distan3)) 00190 { 00191 //led1 = 0; 00192 led2 = 1; 00193 led3 = 0; 00194 led4 = 0; 00195 00196 if(uart.writeable()) 00197 { 00198 uart.printf("%c",a); 00199 led3 = 1; 00200 wait(0.3); 00201 } 00202 00203 //uLCD.locate(0,14); 00204 //uLCD.printf("Forward, tilt to left!"); 00205 } 00206 // 'z' - tilt to right. 00207 if((diffLR<100) && (distan1<distan3)) 00208 { 00209 led1 = 0; 00210 led2 = 0; 00211 //led3 = 0; 00212 led4 = 1; 00213 00214 if(uart.writeable()) 00215 { 00216 uart.printf("%c",z); 00217 led3 = 1; 00218 wait(0.3); 00219 } 00220 00221 00222 //uLCD.locate(0,14); 00223 //uLCD.printf("Forward, tilt to right!"); 00224 } 00225 00226 //feedback with one side (left/right) 00227 // compare front and back distance and adjust!!!!! // NOT BEEN CODED YET 00228 if((distan3>300) && (distan3b<100)) 00229 { 00230 led1 = 1; 00231 led2 = 0; 00232 led3 = 1; 00233 led4 = 1; 00234 00235 //move forward 00236 00237 if(uart.writeable()) 00238 { 00239 uart.printf("%c",f); 00240 //led3 = 1; 00241 wait(0.3); 00242 } 00243 00244 //uLCD.locate(0,14); 00245 //uLCD.printf("Forward, One FB, Left\n"); 00246 // SAME AS ABOVE 00247 } 00248 00249 if((distan1>300) && (distan1b<100)) 00250 { 00251 led1 = 1; 00252 led2 = 1; 00253 led3 = 1; 00254 led4 = 0; 00255 00256 if(uart.writeable()) 00257 { 00258 uart.printf("%c",f); 00259 wait(0.3); 00260 //led3 = 1; 00261 } 00262 00263 //uLCD.locate(0,14); 00264 //uLCD.printf("Forward, One FB, Right\n"); 00265 } 00266 00267 00268 00269 ////////////detecting parking spaces on the LEFT SIDE//////////// 00270 00271 if((distan1>300) && (distan1b>300)) 00272 { 00273 l1Sensor = true; 00274 l2Sensor = true; 00275 00276 //parking space is on the left side 00277 led1 = 0; 00278 led2 = 1; 00279 led3 = 1; 00280 led4 = 0; 00281 00282 00283 if(uart.writeable()) 00284 { 00285 00286 uart.printf("%c",w); 00287 wait(3); 00288 } 00289 00290 left1.checkDistance(); 00291 left2.checkDistance(); 00292 backr.checkDistance(); 00293 backl.checkDistance(); 00294 right1.checkDistance(); 00295 right2.checkDistance(); 00296 00297 wait(2); 00298 00299 00300 while(abs((distan2r)-(distan2l)) >15 ) 00301 { 00302 left1.checkDistance(); 00303 left2.checkDistance(); 00304 backr.checkDistance(); 00305 backl.checkDistance(); 00306 right1.checkDistance(); 00307 right2.checkDistance(); 00308 wait(1); 00309 00310 if(distan2r > distan2l) 00311 { 00312 uart.printf("%c",h); 00313 left1.checkDistance(); 00314 left2.checkDistance(); 00315 backr.checkDistance(); 00316 backl.checkDistance(); 00317 right1.checkDistance(); 00318 right2.checkDistance(); 00319 00320 wait(1); 00321 } 00322 00323 if(distan2r < distan2l) 00324 { 00325 uart.printf("%c",g); 00326 left1.checkDistance(); 00327 left2.checkDistance(); 00328 backr.checkDistance(); 00329 backl.checkDistance(); 00330 right1.checkDistance(); 00331 right2.checkDistance(); 00332 00333 wait(1); 00334 } 00335 00336 } 00337 00338 00339 //move forward 00340 while((distan1 > 200)||(distan3 > 200)) 00341 { 00342 front.checkDistance(); 00343 left1.checkDistance(); 00344 left2.checkDistance(); 00345 //back.checkDistance(); 00346 right1.checkDistance(); 00347 right2.checkDistance(); 00348 00349 if((distan1 > 200)||(distan3 > 200)) 00350 { 00351 uart.printf("%c",f); 00352 wait(0.3); 00353 front.checkDistance(); 00354 left1.checkDistance(); 00355 left2.checkDistance(); 00356 //back.checkDistance(); 00357 right1.checkDistance(); 00358 right2.checkDistance(); 00359 } 00360 } 00361 00362 while(distan0>130) 00363 { 00364 00365 front.checkDistance(); //call checkDistance() as much as possible, as this is where 00366 //the class checks if dist needs to be called. 00367 left1.checkDistance(); 00368 left2.checkDistance(); 00369 backr.checkDistance(); 00370 backl.checkDistance(); 00371 right1.checkDistance(); 00372 right2.checkDistance(); 00373 00374 //tilt to the right 00375 if(distan1>distan3) 00376 { 00377 uart.printf("%c",z); 00378 led3 = 1; 00379 wait(0.3); 00380 } 00381 //tilt to the left 00382 if(distan1<distan3) 00383 { 00384 uart.printf("%c",a); 00385 led3 = 1; 00386 wait(0.3); 00387 } 00388 front.checkDistance(); //call checkDistance() as much as possible, as this is where 00389 //the class checks if dist needs to be called. 00390 left1.checkDistance(); 00391 left2.checkDistance(); 00392 backr.checkDistance(); 00393 backl.checkDistance(); 00394 right1.checkDistance(); 00395 right2.checkDistance(); 00396 } 00397 00398 uart.printf("%c",r); 00399 00400 00401 00402 left1.checkDistance(); 00403 left2.checkDistance(); 00404 backr.checkDistance(); 00405 backl.checkDistance(); 00406 right1.checkDistance(); 00407 right2.checkDistance(); 00408 00409 wait(2); 00410 00411 00412 while(abs((distan2r)-(distan2l)) >15 ) 00413 { 00414 left1.checkDistance(); 00415 left2.checkDistance(); 00416 backr.checkDistance(); 00417 backl.checkDistance(); 00418 right1.checkDistance(); 00419 right2.checkDistance(); 00420 wait(1); 00421 00422 if(distan2r > distan2l) 00423 { 00424 uart.printf("%c",h); 00425 left1.checkDistance(); 00426 left2.checkDistance(); 00427 backr.checkDistance(); 00428 backl.checkDistance(); 00429 right1.checkDistance(); 00430 right2.checkDistance(); 00431 00432 wait(1); 00433 } 00434 00435 if(distan2r < distan2l) 00436 { 00437 uart.printf("%c",g); 00438 left1.checkDistance(); 00439 left2.checkDistance(); 00440 backr.checkDistance(); 00441 backl.checkDistance(); 00442 right1.checkDistance(); 00443 right2.checkDistance(); 00444 00445 wait(1); 00446 } 00447 00448 } 00449 00450 00451 00452 uart.printf("%c",p); 00453 wait(20); 00454 00455 //uLCD.locate(0,14); 00456 //uLCD.printf("Park, on the left!"); 00457 } 00458 00459 /// /////////parking space is on the right side//////////////////// 00460 if((distan3>300) && (distan3b>300)) 00461 { 00462 l1Sensor = true; 00463 l2Sensor = true; 00464 00465 //parking space is on the left side 00466 led1 = 0; 00467 led2 = 1; 00468 led3 = 1; 00469 led4 = 0; 00470 00471 00472 if(uart.writeable()) 00473 { 00474 00475 uart.printf("%c",x); 00476 wait(3); 00477 } 00478 00479 left1.checkDistance(); 00480 left2.checkDistance(); 00481 backr.checkDistance(); 00482 backl.checkDistance(); 00483 right1.checkDistance(); 00484 right2.checkDistance(); 00485 00486 wait(2); 00487 00488 00489 while(abs((distan2r)-(distan2l)) > 15 ) 00490 { 00491 left1.checkDistance(); 00492 left2.checkDistance(); 00493 backr.checkDistance(); 00494 backl.checkDistance(); 00495 right1.checkDistance(); 00496 right2.checkDistance(); 00497 wait(1); 00498 00499 if(distan2r > distan2l) 00500 { 00501 uart.printf("%c",h); 00502 left1.checkDistance(); 00503 left2.checkDistance(); 00504 backr.checkDistance(); 00505 backl.checkDistance(); 00506 right1.checkDistance(); 00507 right2.checkDistance(); 00508 00509 wait(1); 00510 } 00511 00512 if(distan2r < distan2l) 00513 { 00514 uart.printf("%c",g); 00515 left1.checkDistance(); 00516 left2.checkDistance(); 00517 backr.checkDistance(); 00518 backl.checkDistance(); 00519 right1.checkDistance(); 00520 right2.checkDistance(); 00521 00522 wait(1); 00523 } 00524 00525 } 00526 00527 00528 //move forward 00529 while((distan1 > 200)||(distan3 > 200)) 00530 { 00531 front.checkDistance(); 00532 left1.checkDistance(); 00533 left2.checkDistance(); 00534 //back.checkDistance(); 00535 right1.checkDistance(); 00536 right2.checkDistance(); 00537 00538 if((distan1 > 200)||(distan3 > 200)) 00539 { 00540 uart.printf("%c",f); 00541 wait(0.3); 00542 front.checkDistance(); 00543 left1.checkDistance(); 00544 left2.checkDistance(); 00545 //back.checkDistance(); 00546 right1.checkDistance(); 00547 right2.checkDistance(); 00548 } 00549 } 00550 00551 while(distan0>130) 00552 { 00553 00554 front.checkDistance(); //call checkDistance() as much as possible, as this is where 00555 //the class checks if dist needs to be called. 00556 left1.checkDistance(); 00557 left2.checkDistance(); 00558 backr.checkDistance(); 00559 backl.checkDistance(); 00560 right1.checkDistance(); 00561 right2.checkDistance(); 00562 00563 //tilt to the right 00564 if(distan1>distan3) 00565 { 00566 uart.printf("%c",z); 00567 led3 = 1; 00568 wait(0.3); 00569 } 00570 //tilt to the left 00571 if(distan1<distan3) 00572 { 00573 uart.printf("%c",a); 00574 led3 = 1; 00575 wait(0.3); 00576 } 00577 front.checkDistance(); //call checkDistance() as much as possible, as this is where 00578 //the class checks if dist needs to be called. 00579 left1.checkDistance(); 00580 left2.checkDistance(); 00581 backr.checkDistance(); 00582 backl.checkDistance(); 00583 right1.checkDistance(); 00584 right2.checkDistance(); 00585 } 00586 00587 uart.printf("%c",l); 00588 00589 00590 00591 left1.checkDistance(); 00592 left2.checkDistance(); 00593 backr.checkDistance(); 00594 backl.checkDistance(); 00595 right1.checkDistance(); 00596 right2.checkDistance(); 00597 00598 wait(2); 00599 00600 00601 while(abs((distan2r)-(distan2l)) >15 ) 00602 { 00603 left1.checkDistance(); 00604 left2.checkDistance(); 00605 backr.checkDistance(); 00606 backl.checkDistance(); 00607 right1.checkDistance(); 00608 right2.checkDistance(); 00609 wait(1); 00610 00611 if(distan2r > distan2l) 00612 { 00613 uart.printf("%c",h); 00614 left1.checkDistance(); 00615 left2.checkDistance(); 00616 backr.checkDistance(); 00617 backl.checkDistance(); 00618 right1.checkDistance(); 00619 right2.checkDistance(); 00620 00621 wait(1); 00622 } 00623 00624 if(distan2r < distan2l) 00625 { 00626 uart.printf("%c",g); 00627 left1.checkDistance(); 00628 left2.checkDistance(); 00629 backr.checkDistance(); 00630 backl.checkDistance(); 00631 right1.checkDistance(); 00632 right2.checkDistance(); 00633 00634 wait(1); 00635 } 00636 00637 } 00638 00639 00640 00641 uart.printf("%c",p); 00642 wait(20); 00643 00644 //uLCD.locate(0,14); 00645 //uLCD.printf("Park, on the left!"); 00646 } 00647 } 00648 //if(distan0<50) 00649 00650 //FRONT SENSOR ON 00651 else 00652 { 00653 //cornering feature 00654 00655 ///////////////////////////////////////////////turning left////////////////////////////////////////////// 00656 if((distan1>300)&&(distan1b>300)) 00657 { 00658 led1 = 1; 00659 led2 = 0; 00660 led3 = 1; 00661 led4 =1; 00662 00663 uart.printf("%c",f); 00664 wait(.3); 00665 00666 if(uart.writeable()) 00667 { 00668 uart.printf("%c",l); 00669 wait(2); 00670 //led3 = 1; 00671 } 00672 00673 left1.checkDistance(); 00674 left2.checkDistance(); 00675 right1.checkDistance(); 00676 right2.checkDistance(); 00677 wait(2); 00678 00679 // checking on the left. adjust the angle and make sure it's pointing at the right direction 00680 while( abs((distan3)-(distan3b)) >15 ) 00681 { 00682 left1.checkDistance(); 00683 left2.checkDistance(); 00684 right1.checkDistance(); 00685 right2.checkDistance(); 00686 00687 wait(1); 00688 00689 if(distan3 > distan3b) 00690 { 00691 uart.printf("%c",h); 00692 left1.checkDistance(); 00693 left2.checkDistance(); 00694 right1.checkDistance(); 00695 right2.checkDistance(); 00696 00697 wait(1); 00698 } 00699 00700 if(distan3 <distan3b) 00701 { 00702 uart.printf("%c",g); 00703 left1.checkDistance(); 00704 left2.checkDistance(); 00705 right1.checkDistance(); 00706 right2.checkDistance(); 00707 00708 wait(1); 00709 } 00710 00711 00712 } 00713 00714 //after turning left, if there are space open on the left, focus on the left wall 00715 while((distan1>220)||(distan1b>220)) 00716 { 00717 //front.checkDistance(); //call checkDistance() as much as possible, as this is where 00718 //the class checks if dist needs to be called. 00719 left1.checkDistance(); 00720 left2.checkDistance(); 00721 //back.checkDistance(); 00722 right1.checkDistance(); 00723 right2.checkDistance(); 00724 00725 00726 if((distan3>distan3b)) 00727 { 00728 uart.printf("%c",z); 00729 wait(.3); 00730 left1.checkDistance(); 00731 left2.checkDistance(); 00732 //back.checkDistance(); 00733 right1.checkDistance(); 00734 right2.checkDistance(); 00735 } 00736 if((distan3<distan3b)) 00737 { 00738 uart.printf("%c",a); 00739 wait(.3); 00740 left1.checkDistance(); 00741 left2.checkDistance(); 00742 //back.checkDistance(); 00743 right1.checkDistance(); 00744 right2.checkDistance(); 00745 } 00746 } 00747 //uLCD.locate(0,14); 00748 // uLCD.printf("Right!"); 00749 } 00750 00751 ////////////////////////////////////////turning right///////////////////////////////////// 00752 if((distan3>300)&&(distan3b>300)) 00753 { 00754 led1 = 1; 00755 led2 = 0; 00756 led3 = 1; 00757 led4 =1; 00758 00759 uart.printf("%c",f); 00760 wait(.3); 00761 00762 if(uart.writeable()) 00763 { 00764 uart.printf("%c",r); 00765 wait(2); 00766 //led3 = 1; 00767 } 00768 00769 left1.checkDistance(); 00770 left2.checkDistance(); 00771 right1.checkDistance(); 00772 right2.checkDistance(); 00773 wait(2); 00774 00775 // checking on the left. adjust the angle and make sure it's pointing at the right direction 00776 while( abs((distan1)-(distan1b)) >15 ) 00777 { 00778 left1.checkDistance(); 00779 left2.checkDistance(); 00780 right1.checkDistance(); 00781 right2.checkDistance(); 00782 00783 wait(1); 00784 00785 if(distan1 > distan1b) 00786 { 00787 uart.printf("%c",g); 00788 left1.checkDistance(); 00789 left2.checkDistance(); 00790 right1.checkDistance(); 00791 right2.checkDistance(); 00792 00793 wait(1); 00794 } 00795 00796 if(distan1 <distan1b) 00797 { 00798 uart.printf("%c",h); 00799 left1.checkDistance(); 00800 left2.checkDistance(); 00801 right1.checkDistance(); 00802 right2.checkDistance(); 00803 00804 wait(1); 00805 } 00806 00807 00808 } 00809 00810 //after turning right, if there are space open on the right, focus on the left wall 00811 while((distan3>220)||(distan3b>220)) 00812 { 00813 //front.checkDistance(); //call checkDistance() as much as possible, as this is where 00814 //the class checks if dist needs to be called. 00815 left1.checkDistance(); 00816 left2.checkDistance(); 00817 //back.checkDistance(); 00818 right1.checkDistance(); 00819 right2.checkDistance(); 00820 00821 00822 if((distan1>distan1b)) 00823 { 00824 uart.printf("%c",a); 00825 wait(.3); 00826 left1.checkDistance(); 00827 left2.checkDistance(); 00828 //back.checkDistance(); 00829 right1.checkDistance(); 00830 right2.checkDistance(); 00831 } 00832 if((distan1<distan1b)) 00833 { 00834 uart.printf("%c",z); 00835 wait(.3); 00836 left1.checkDistance(); 00837 left2.checkDistance(); 00838 //back.checkDistance(); 00839 right1.checkDistance(); 00840 right2.checkDistance(); 00841 } 00842 } 00843 //uLCD.locate(0,14); 00844 // uLCD.printf("Right!"); 00845 } 00846 00847 //parking stop condition 00848 if((diffLR < 30) && (diffLR2 < 30) &&(distan0 < 50)) 00849 { 00850 led1 = 1; 00851 led2 = 1; 00852 led3 = 1; 00853 led4 = 1; 00854 00855 if(uart.writeable()) 00856 { 00857 uart.printf("%c",p); 00858 wait(0.3); 00859 //led3 = 1; 00860 } 00861 00862 //uLCD.locate(0,14); 00863 // uLCD.printf("PARK DONE"); 00864 } 00865 } 00866 00867 00868 } 00869 00870 00871 //////////////////////////////////////////////////////////////////////// 00872 00873 00874 00875 } 00876 00877 else 00878 { 00879 //add release code here 00880 } 00881 break; 00882 00883 case '2': //number button 2 00884 if (bhit=='1') { 00885 //add hit code here 00886 00887 if(uart.writeable()) 00888 { 00889 uart.printf("%c",a); 00890 } 00891 00892 } else { 00893 //add release code here 00894 } 00895 break; 00896 case '3': //number button 3 00897 if (bhit=='1') { 00898 //add hit code here 00899 00900 if(uart.writeable()) 00901 { 00902 uart.printf("%c",z); 00903 } 00904 00905 } else { 00906 //add release code here 00907 } 00908 break; 00909 case '4': //number button 4 00910 if (bhit=='1') { 00911 //add hit code here 00912 } else { 00913 //add release code here 00914 } 00915 break; 00916 case '5': //button 5 up arrow 00917 if (bhit=='1') { 00918 //add hit code here 00919 //uLCD.locate(0,1); 00920 //uLCD.printf("Moving Forward"); 00921 led1 = 1; 00922 led2 = 0; 00923 led3 = 0; 00924 led4 = 0; 00925 00926 if(uart.writeable()) 00927 { 00928 uart.printf("%c",f); 00929 //led3 = 1; 00930 } 00931 00932 } else { 00933 //add release code here 00934 } 00935 break; 00936 case '6': //button 6 down arrow 00937 if (bhit=='1') { 00938 //add hit code here 00939 // uLCD.locate(0,1); 00940 //uLCD.printf("Moving Back"); 00941 led1 = 0; 00942 led2 = 0; 00943 led3 = 1; 00944 led4 = 0; 00945 00946 if(uart.writeable()) 00947 { 00948 uart.printf("%c",b); 00949 } 00950 00951 } else { 00952 //add release code here 00953 } 00954 break; 00955 case '7': //button 7 left arrow 00956 if (bhit=='1') { 00957 //add hit code here 00958 //uLCD.locate(0,1); 00959 //uLCD.printf("Moving Left"); 00960 led1 = 0; 00961 led2 = 1; 00962 led3 = 0; 00963 led4 = 0; 00964 00965 if(uart.writeable()) 00966 { 00967 uart.printf("%c",l); 00968 } 00969 00970 } else { 00971 //add release code here 00972 } 00973 break; 00974 case '8': //button 8 right arrow 00975 if (bhit=='1') { 00976 //add hit code here 00977 //uLCD.locate(0,1); 00978 //uLCD.printf("Moving Right"); 00979 led1 = 0; 00980 led2 = 0; 00981 led3 = 0; 00982 led4 = 1; 00983 00984 if(uart.writeable()) 00985 { 00986 uart.printf("%c",r); 00987 } 00988 00989 } else { 00990 //add release code here 00991 } 00992 break; 00993 default: 00994 break; 00995 } 00996 } 00997 } 00998 } 00999 } 01000 }
Generated on Fri Jul 22 2022 23:16:01 by
1.7.2