![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
First Draft, serial print change based on distance
Diff: main.cpp
- Revision:
- 13:cc99df342c7f
- Parent:
- 10:be53044119d1
- Child:
- 14:837945ccd8c0
--- a/main.cpp Thu Feb 03 18:36:34 2022 +0000 +++ b/main.cpp Thu Feb 03 21:43:40 2022 +0000 @@ -21,7 +21,6 @@ { R.mode(PullDown); - L.mode(PullDown); Start.mode(PullDown); Start.rise(Start_isr); Back.mode(PullDown); @@ -70,7 +69,7 @@ lcd.clear(); Start_flag = 0; int select = 0; - output = 63; // 63 on the bus output sets all LEDs to off + LEDS = 63; // 63 on the bus output sets all LEDs to off while (1) { @@ -150,7 +149,7 @@ while(1) { - output = fsm[state]; // output current state + LEDS = fsm[state]; // output current state printf("state = %d\r\n",state); // check which state we are in and see which the next state should be @@ -159,7 +158,8 @@ lcd.clear(); lcd.printString(" object at 0'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ state = 1;} @@ -176,7 +176,8 @@ lcd.clear(); lcd.printString(" object at 60'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ state = 2;} @@ -192,7 +193,8 @@ lcd.clear(); lcd.printString(" object at 120'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ state = 3;} @@ -209,7 +211,8 @@ lcd.clear(); lcd.printString(" object at 180'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ state = 4;} @@ -226,7 +229,8 @@ lcd.clear(); lcd.printString(" object at 240'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ state = 5;} @@ -243,7 +247,8 @@ lcd.clear(); lcd.printString(" object at 300'",0,0); lcd.printString(" R + 60'",0,2); - lcd.printString(" L - 60'",0,4); + lcd.printString("Start to take",0,4); + lcd.printString(" Reading ",0,5); lcd.refresh(); if (R == 1){ object_detection();} @@ -330,7 +335,7 @@ sense = 1; Distance1 = mu.getCurrentDistance(); - + printf("distance at sense 1 = %d\r\n", Distance1); } @@ -394,14 +399,14 @@ //printf("glass[6] = %d\n", glass[6]); if (abs(Distance1 - glass[0]) <= 10 and abs(Distance2 - glass[1]) <= 10 and abs(Distance3 - glass[2]) <= 10 and abs(Distance4 - glass[3]) <= 10 and abs(Distance5 - glass[4]) <= 10 and abs(Distance6 - glass[5]) <= 10){ printf("glass\n"); - lcd.printString("Object Found!",0,1); - lcd.printString("Pint Glass",0,3); + lcd.printString(" Object Found!",0,1); + lcd.printString(" Pint Glass",0,3); lcd.refresh();} else{ printf("nothing\n"); - lcd.printString("No Object",0,1); - lcd.printString("Please Try",0,3); + lcd.printString(" No Object!",0,1); + lcd.printString(" Please Try",0,3); lcd.printString("Again",24,4); lcd.refresh();} }