GT ECE 4180 Lab Team - Raj Madisetti and Arjun Sonti
Dependencies: mbed Servo Motordriver X_NUCLEO_53L0A1 HC_SR04_Ultrasonic_Library
Remote Control Car
Georgia Tech ECE 4180 Embedded Systems Design Final Project
Team Members
Raj Madisetti Arjun Sonti
Revision 5:b1b250500440, committed 2020-11-27
- Comitter:
- rmadisetti3
- Date:
- Fri Nov 27 20:45:42 2020 +0000
- Parent:
- 4:29839de66eae
- Commit message:
- Final
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Nov 19 21:19:12 2020 +0000
+++ b/main.cpp Fri Nov 27 20:45:42 2020 +0000
@@ -16,6 +16,7 @@
int state = 0; //global variable stop state
int status1;
int status2;
+int autoPilotLock;
int distanceCenter;
int distanceLeft;
int distanceRight;
@@ -56,12 +57,12 @@
break;
case '7': //left
if (bhit=='1') {
- S = S - 0.5; //turn left
+ S = S + 0.5; //turn left
}
break;
case '8': //right
if (bhit=='1') {
- S = S + 0.5; //turn right
+ S = S - 0.5; //turn right
}
break;
}
@@ -72,15 +73,24 @@
}
void autoPilot() {
- if (distanceCenter >= 250) {
+ autoPilotLock = 0;
+ if (distanceCenter >= 200 && autoPilotLock == 0) {
M.speed(1.0);
S = 0.5;
}
else if (distanceRight > distanceLeft) { //More space on right so turn right
- S = 1.0;
+ autoPilotLock = 1;
+ M.speed(-1.0);
+ S = 0;
+ wait_ms(1000);
+ autoPilotLock = 0;
}
else { //or turn left
- S = 0;
+ autoPilotLock = 1;
+ M.speed(-1.0);
+ S = 1.0;
+ wait_ms(1000);
+ autoPilotLock = 0;
}
}
