The user controls the car via bluetooth through the Bluefruit LE app. The user can switch between a "sem-auto" mode and a manual mode.

Dependencies:   Motor Ultrasonic_HCSR04_HelloWorld_code mbed

Introduction :

This is a mini-project for the final semester of my sophomore year on assembling and interfacing a semi-automatic bluetooth controlled car with the help of mbed-LPC1768. This was one of the semester projects intended for evaluation to fulfill the requirements for attaining an undergraduate degree ( Bachelor's of Technology) in Electronics and Communication Engineering.

The user can switch to an "auto-pilot" like mode by activating the functionality of the sonar sensor, thus giving complete control to the user by allowing the user to switch between manual and semi-autopilot mode. When an obstacle is detected by the sensor the bot is stopped by the sensor. Differential torque has been used to turn the car.

/media/uploads/Rohit99/project_image.jpg

Future Prospectives :

(1) Adding a few more sonar sensors on the bot to detect objects surrounding it simultaneously and automate the whole process or allowing the user to switch between a complete autopilot mode, a semi-autopilot mode and a manual mode.

(2) Integrating Simultaneous Localization and Mapping (SLAM) with the bot so that it can update a map of an unknown environment while simultaneously keeping track of an agent’s location within it using deep neural networks. (3) Adding a few gas and dust sensors to make a mobile weather station.

References :

The references mentioned below were of great help :

I would also like to acknowledge jlogreira3 for his/her project.

Committer:
Rohit99
Date:
Sat May 19 10:52:32 2018 +0000
Revision:
0:c37818d82347
Done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit99 0:c37818d82347 1 // Project
Rohit99 0:c37818d82347 2 #include "mbed.h"
Rohit99 0:c37818d82347 3 #include "Motor.h"
Rohit99 0:c37818d82347 4 #include "ultrasonic.h"
Rohit99 0:c37818d82347 5
Rohit99 0:c37818d82347 6 Serial pc (USBTX, USBRX);
Rohit99 0:c37818d82347 7 BusOut myled(LED1,LED2,LED3,LED4);
Rohit99 0:c37818d82347 8 Serial blue(p28,p27);
Rohit99 0:c37818d82347 9 Motor motorA(p23, p6, p5); // pwm, fwd, rev
Rohit99 0:c37818d82347 10 Motor motorB(p24, p11, p12); // pwm, fwd, rev
Rohit99 0:c37818d82347 11
Rohit99 0:c37818d82347 12 int dist;
Rohit99 0:c37818d82347 13
Rohit99 0:c37818d82347 14 void dist_func(int distance)
Rohit99 0:c37818d82347 15 {
Rohit99 0:c37818d82347 16 //put code here to execute when the distance has changed
Rohit99 0:c37818d82347 17 pc.printf("Distance %d mm\r\n", distance);
Rohit99 0:c37818d82347 18 dist = distance;
Rohit99 0:c37818d82347 19 }
Rohit99 0:c37818d82347 20 ultrasonic mu(p6, p7, .1, 1, &dist_func);
Rohit99 0:c37818d82347 21
Rohit99 0:c37818d82347 22 int main()
Rohit99 0:c37818d82347 23 {
Rohit99 0:c37818d82347 24 float motorSpeed_A = 0.0;
Rohit99 0:c37818d82347 25 float motorSpeed_B = 0.0;
Rohit99 0:c37818d82347 26 char bnum = 0;
Rohit99 0:c37818d82347 27 char bhit = 0;
Rohit99 0:c37818d82347 28 mu.startUpdates();//start measuring the distance
Rohit99 0:c37818d82347 29 while(1)
Rohit99 0:c37818d82347 30 {
Rohit99 0:c37818d82347 31 motorA.speed(motorSpeed_A);
Rohit99 0:c37818d82347 32 motorB.speed(motorSpeed_B);
Rohit99 0:c37818d82347 33 if (blue.getc() == '!') {
Rohit99 0:c37818d82347 34 if (blue.getc() == 'B') { //button data packet
Rohit99 0:c37818d82347 35 bnum = blue.getc(); //button number
Rohit99 0:c37818d82347 36 bhit = blue.getc(); //1=hit, 0=release
Rohit99 0:c37818d82347 37 if (blue.getc() == char(~('!' + 'B' + bnum + bhit))) { //checksum OK?
Rohit99 0:c37818d82347 38 myled = bnum - '1'; //current button number will appear on LEDs
Rohit99 0:c37818d82347 39 switch (bnum) {
Rohit99 0:c37818d82347 40 case '1' : // number button 1
Rohit99 0:c37818d82347 41 if (bhit == '1'){
Rohit99 0:c37818d82347 42 }
Rohit99 0:c37818d82347 43 else {
Rohit99 0:c37818d82347 44 mu.checkDistance();
Rohit99 0:c37818d82347 45 if (dist <= 50){
Rohit99 0:c37818d82347 46 motorSpeed_A = 0.0; // Stop
Rohit99 0:c37818d82347 47 motorSpeed_B = 0.0; // Stop
Rohit99 0:c37818d82347 48 }
Rohit99 0:c37818d82347 49 }
Rohit99 0:c37818d82347 50 break;
Rohit99 0:c37818d82347 51 case '2' : // number button 2
Rohit99 0:c37818d82347 52 if (bhit == '1'){
Rohit99 0:c37818d82347 53 }
Rohit99 0:c37818d82347 54 else {
Rohit99 0:c37818d82347 55 motorSpeed_A -= 0.2; // decreasing speed
Rohit99 0:c37818d82347 56 motorSpeed_B -= 0.2; // decreasing speed
Rohit99 0:c37818d82347 57 }
Rohit99 0:c37818d82347 58 break;
Rohit99 0:c37818d82347 59 case '3' : // number button 3
Rohit99 0:c37818d82347 60 if(bhit == '1'){
Rohit99 0:c37818d82347 61 }
Rohit99 0:c37818d82347 62 else {
Rohit99 0:c37818d82347 63 motorSpeed_A = 0.0; // Stop
Rohit99 0:c37818d82347 64 motorSpeed_B = 0.0; // Stop
Rohit99 0:c37818d82347 65 }
Rohit99 0:c37818d82347 66 break;
Rohit99 0:c37818d82347 67 case '4' : // Reverse Rotation
Rohit99 0:c37818d82347 68 // Hitting 4 on the numpad activates reverse mode and turns
Rohit99 0:c37818d82347 69 if (bhit == '1'){
Rohit99 0:c37818d82347 70 }
Rohit99 0:c37818d82347 71 else {
Rohit99 0:c37818d82347 72 if (blue.getc() == '!') {
Rohit99 0:c37818d82347 73 if (blue.getc() == 'B') { //button data packet
Rohit99 0:c37818d82347 74 bnum = blue.getc(); //button number
Rohit99 0:c37818d82347 75 bhit = blue.getc(); //1=hit, 0=release
Rohit99 0:c37818d82347 76 if (blue.getc() == char(~('!' + 'B' + bnum + bhit))) {
Rohit99 0:c37818d82347 77 // For reverse turn
Rohit99 0:c37818d82347 78 myled = bnum - '1';
Rohit99 0:c37818d82347 79 switch (bnum) {
Rohit99 0:c37818d82347 80 case '7' : // arrow left
Rohit99 0:c37818d82347 81 if (bhit == '1'){
Rohit99 0:c37818d82347 82 }
Rohit99 0:c37818d82347 83 else {
Rohit99 0:c37818d82347 84 motorSpeed_A = -0.5;
Rohit99 0:c37818d82347 85 motorSpeed_B = -0.1;
Rohit99 0:c37818d82347 86 }
Rohit99 0:c37818d82347 87 break;
Rohit99 0:c37818d82347 88 case '8' : // arrow right
Rohit99 0:c37818d82347 89 if (bhit == '1'){
Rohit99 0:c37818d82347 90 }
Rohit99 0:c37818d82347 91 else {
Rohit99 0:c37818d82347 92 motorSpeed_A = -0.1;
Rohit99 0:c37818d82347 93 motorSpeed_B = -0.5;
Rohit99 0:c37818d82347 94 }
Rohit99 0:c37818d82347 95 default:
Rohit99 0:c37818d82347 96 break;
Rohit99 0:c37818d82347 97 }
Rohit99 0:c37818d82347 98 }
Rohit99 0:c37818d82347 99 }
Rohit99 0:c37818d82347 100 }
Rohit99 0:c37818d82347 101 break;
Rohit99 0:c37818d82347 102 case '5' : // arrow up button
Rohit99 0:c37818d82347 103 if (bhit == '1') {
Rohit99 0:c37818d82347 104 //add hit code here
Rohit99 0:c37818d82347 105 motorSpeed_A += 0.2; // increasing speed
Rohit99 0:c37818d82347 106 motorSpeed_B += 0.2; // increasing speed
Rohit99 0:c37818d82347 107 }
Rohit99 0:c37818d82347 108 break;
Rohit99 0:c37818d82347 109 case '6' : // arrow down
Rohit99 0:c37818d82347 110 if (bhit == '1') {
Rohit99 0:c37818d82347 111 }
Rohit99 0:c37818d82347 112 else {
Rohit99 0:c37818d82347 113 motorSpeed_A -= 0.2; // decreasing speed
Rohit99 0:c37818d82347 114 motorSpeed_B -= 0.2; // decreasing speed
Rohit99 0:c37818d82347 115 }
Rohit99 0:c37818d82347 116 break;
Rohit99 0:c37818d82347 117 case '7' : // arrow left
Rohit99 0:c37818d82347 118 if (bhit == '1'){
Rohit99 0:c37818d82347 119 }
Rohit99 0:c37818d82347 120 else {
Rohit99 0:c37818d82347 121 motorSpeed_A = 0.5;
Rohit99 0:c37818d82347 122 motorSpeed_B = 0.1;
Rohit99 0:c37818d82347 123 }
Rohit99 0:c37818d82347 124 break;
Rohit99 0:c37818d82347 125 case '8' : // arrow right
Rohit99 0:c37818d82347 126 if (bhit == '1'){
Rohit99 0:c37818d82347 127 }
Rohit99 0:c37818d82347 128 else {
Rohit99 0:c37818d82347 129 motorSpeed_A = 0.1;
Rohit99 0:c37818d82347 130 motorSpeed_B = 0.5;
Rohit99 0:c37818d82347 131 }
Rohit99 0:c37818d82347 132 //break;
Rohit99 0:c37818d82347 133 default :
Rohit99 0:c37818d82347 134 break;
Rohit99 0:c37818d82347 135 }
Rohit99 0:c37818d82347 136 }
Rohit99 0:c37818d82347 137 }
Rohit99 0:c37818d82347 138 }
Rohit99 0:c37818d82347 139 }
Rohit99 0:c37818d82347 140 }
Rohit99 0:c37818d82347 141 }