├── .gitignore ├── Bluetooth (Controlled Robot) Sketch.ino ├── Final sketch(final code).ino ├── LICENSE ├── Obstacle Avoider Sketch.ino ├── README.md ├── Wall Follower Sketch.ino └── guide.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /Bluetooth (Controlled Robot) Sketch.ino: -------------------------------------------------------------------------------- 1 | 2 | //Libraries 3 | #include 4 | 5 | //Objects 6 | AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm 7 | AF_DCMotor motorLeft(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm 8 | 9 | //Constants and variable 10 | char dataIn = 'S'; 11 | char determinant; 12 | char det; 13 | int vel = 0; //Bluetooth Stuff 14 | 15 | 16 | void setup() { 17 | Serial.begin(9600); // set up Serial library at 9600 bps 18 | 19 | //Initalization messages 20 | Serial.println("ArduinoBymyself - ROVERBot"); 21 | Serial.println(" AF Motor test!"); 22 | 23 | //turn off motors 24 | motorRight.setSpeed(0); 25 | motorLeft.setSpeed(0); 26 | motorRight.run(RELEASE); 27 | motorLeft.run(RELEASE); 28 | 29 | 30 | 31 | } 32 | 33 | void loop() { 34 | det = check(); //call check() subrotine to get the serial code 35 | 36 | //serial code analysis 37 | switch (det){ 38 | case 'F': // F, move forward 39 | motorRight.setSpeed(vel); 40 | motorLeft.setSpeed(vel); 41 | motorRight.run(FORWARD); 42 | motorLeft.run(FORWARD); 43 | det = check(); 44 | break; 45 | 46 | case 'B': // B, move back 47 | motorRight.setSpeed(vel); 48 | motorLeft.setSpeed(vel); 49 | motorRight.run(BACKWARD); 50 | motorLeft.run(BACKWARD); 51 | det = check(); 52 | break; 53 | 54 | case 'L':// L, move wheels left 55 | motorRight.setSpeed(vel); 56 | motorLeft.setSpeed(vel/4); 57 | motorRight.run(FORWARD); 58 | motorLeft.run(FORWARD); 59 | det = check(); 60 | break; 61 | 62 | case 'R': // R, move wheels right 63 | motorRight.setSpeed(vel/4); 64 | motorLeft.setSpeed(vel); 65 | motorRight.run(FORWARD); 66 | motorLeft.run(FORWARD); 67 | det = check(); 68 | break; 69 | 70 | case 'I': // I, turn right forward 71 | motorRight.setSpeed(vel/2); 72 | motorLeft.setSpeed(vel); 73 | motorRight.run(FORWARD); 74 | motorLeft.run(FORWARD); 75 | det = check(); 76 | break; 77 | 78 | case 'J': // J, turn right back 79 | motorRight.setSpeed(vel/2); 80 | motorLeft.setSpeed(vel); 81 | motorRight.run(BACKWARD); 82 | motorLeft.run(BACKWARD); 83 | det = check(); 84 | break; 85 | 86 | case 'G': // G, turn left forward 87 | motorRight.setSpeed(vel); 88 | motorLeft.setSpeed(vel/2); 89 | motorRight.run(FORWARD); 90 | motorLeft.run(FORWARD); 91 | det = check(); 92 | break; 93 | 94 | case 'H': // H, turn left back 95 | motorRight.setSpeed(vel); 96 | motorLeft.setSpeed(vel/2); 97 | motorRight.run(BACKWARD); 98 | motorLeft.run(BACKWARD); 99 | det = check(); 100 | break; 101 | 102 | case 'S': // S, stop 103 | motorRight.setSpeed(vel); 104 | motorLeft.setSpeed(vel); 105 | motorRight.run(RELEASE); 106 | motorLeft.run(RELEASE); 107 | det = check(); 108 | break; 109 | 110 | 111 | 112 | } 113 | } 114 | 115 | //get bluetooth code received from serial port 116 | int check(){ 117 | if (Serial.available() > 0){// if there is valid data in the serial port 118 | dataIn = Serial.read();// stores data into a varialbe 119 | 120 | //check the code 121 | if (dataIn == 'F'){//Forward 122 | determinant = 'F'; 123 | } 124 | else if (dataIn == 'B'){//Backward 125 | determinant = 'B'; 126 | } 127 | else if (dataIn == 'L'){//Left 128 | determinant = 'L'; 129 | } 130 | else if (dataIn == 'R'){//Right 131 | determinant = 'R'; 132 | } 133 | else if (dataIn == 'I'){//Froward Right 134 | determinant = 'I'; 135 | } 136 | else if (dataIn == 'J'){//Backward Right 137 | determinant = 'J'; 138 | } 139 | else if (dataIn == 'G'){//Forward Left 140 | determinant = 'G'; 141 | } 142 | else if (dataIn == 'H'){//Backward Left 143 | determinant = 'H'; 144 | } 145 | else if (dataIn == 'S'){//Stop 146 | determinant = 'S'; 147 | } 148 | else if (dataIn == '0'){//Speed 0 149 | vel = 0; 150 | } 151 | else if (dataIn == '1'){//Speed 25 152 | vel = 25; 153 | } 154 | else if (dataIn == '2'){//Speed 50 155 | vel = 50; 156 | } 157 | else if (dataIn == '3'){//Speed 75 158 | vel = 75; 159 | } 160 | else if (dataIn == '4'){//Speed 100 161 | vel = 100; 162 | } 163 | else if (dataIn == '5'){//Speed 125 164 | vel = 125; 165 | } 166 | else if (dataIn == '6'){//Speed 150 167 | vel = 150; 168 | } 169 | else if (dataIn == '7'){//Speed 175 170 | vel = 175; 171 | } 172 | else if (dataIn == '8'){//Speed 200 173 | vel = 200; 174 | } 175 | else if (dataIn == '9'){//Speed 225 176 | vel = 225; 177 | } 178 | else if (dataIn == 'q'){//Speed 255 179 | vel = 255; 180 | } 181 | else if (dataIn == 'U'){//Back Lights On 182 | determinant = 'U'; 183 | } 184 | else if (dataIn == 'u'){//Back Lights Off 185 | determinant = 'u'; 186 | } 187 | else if (dataIn == 'W'){//Front Lights On 188 | determinant = 'W'; 189 | } 190 | else if (dataIn == 'w'){//Front Lights Off 191 | determinant = 'w'; 192 | } 193 | else if (dataIn == 'V'){//Horn On 194 | determinant = 'V'; 195 | } 196 | else if (dataIn == 'v'){//Horn Off 197 | determinant = 'v'; 198 | } 199 | else if (dataIn == 'X'){//Extra On 200 | determinant = 'X'; 201 | } 202 | else if (dataIn == 'x'){//Extra Off 203 | determinant = 'x'; 204 | } 205 | } 206 | return determinant; 207 | } 208 | 209 | 210 | -------------------------------------------------------------------------------- /Final sketch(final code).ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #define trigPin 14 // define the pins of your sensor 5 | #define echoPin 15 6 | 7 | //Objects 8 | AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm 9 | AF_DCMotor motorLeft(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm 10 | 11 | //Constants and variable 12 | char dataIn = 'S'; 13 | char determinant; 14 | char det; 15 | int vel = 255; //Bluetooth Stuff 16 | 17 | void setup() { 18 | Serial.begin(9600); // set up Serial library at 9600 bps 19 | 20 | pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves) 21 | pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves) 22 | 23 | //Initalization messages 24 | Serial.println(" Mr.robot"); 25 | Serial.println(" Reday for working!"); 26 | 27 | //turn off motors 28 | motorRight.setSpeed(0); 29 | motorLeft.setSpeed(0); 30 | motorRight.run(RELEASE); 31 | motorLeft.run(RELEASE); 32 | } 33 | 34 | void loop() { 35 | det = check(); //call check() subrotine to get the serial code 36 | //serial code analysis 37 | switch (det){ 38 | case 'F': // F, move forward 39 | motorRight.setSpeed(vel); 40 | motorLeft.setSpeed(vel); 41 | motorRight.run(FORWARD); 42 | motorLeft.run(FORWARD); 43 | det = check(); 44 | break; 45 | 46 | case 'B': // B, move back 47 | motorRight.setSpeed(vel); 48 | motorLeft.setSpeed(vel); 49 | motorRight.run(BACKWARD); 50 | motorLeft.run(BACKWARD); 51 | det = check(); 52 | break; 53 | 54 | case 'L':// L, move wheels left 55 | motorRight.setSpeed(vel); 56 | motorLeft.setSpeed(vel/4); 57 | motorRight.run(FORWARD); 58 | motorLeft.run(FORWARD); 59 | det = check(); 60 | break; 61 | 62 | case 'R': // R, move wheels right 63 | motorRight.setSpeed(vel/4); 64 | motorLeft.setSpeed(vel); 65 | motorRight.run(FORWARD); 66 | motorLeft.run(FORWARD); 67 | det = check(); 68 | break; 69 | 70 | case 'I': // I, turn right forward 71 | motorRight.setSpeed(vel/2); 72 | motorLeft.setSpeed(vel); 73 | motorRight.run(FORWARD); 74 | motorLeft.run(FORWARD); 75 | det = check(); 76 | break; 77 | 78 | case 'J': // J, turn right back 79 | motorRight.setSpeed(vel/2); 80 | motorLeft.setSpeed(vel); 81 | motorRight.run(BACKWARD); 82 | motorLeft.run(BACKWARD); 83 | det = check(); 84 | break; 85 | 86 | case 'G': // G, turn left forward 87 | motorRight.setSpeed(vel); 88 | motorLeft.setSpeed(vel/2); 89 | motorRight.run(FORWARD); 90 | motorLeft.run(FORWARD); 91 | det = check(); 92 | break; 93 | 94 | case 'H': // H, turn left back 95 | motorRight.setSpeed(vel); 96 | motorLeft.setSpeed(vel/2); 97 | motorRight.run(BACKWARD); 98 | motorLeft.run(BACKWARD); 99 | det = check(); 100 | break; 101 | 102 | case 'S': 103 | // S, stop 104 | motorRight.setSpeed(vel); 105 | motorLeft.setSpeed(vel); 106 | motorRight.run(RELEASE); 107 | motorLeft.run(RELEASE); 108 | det = check(); 109 | break; 110 | 111 | case 'm': 112 | 113 | //for wall follower robot. 114 | motorRight.setSpeed(vel); //set the speed of the motors, between 0-255 115 | motorLeft.setSpeed (vel); 116 | 117 | long duration, distance; // start the scan 118 | digitalWrite(trigPin, LOW); 119 | delayMicroseconds(2); // delays are required for a succesful sensor operation. 120 | digitalWrite(trigPin, HIGH); 121 | 122 | delayMicroseconds(10); //this delay is required as well! 123 | digitalWrite(trigPin, LOW); 124 | duration = pulseIn(echoPin, HIGH); 125 | distance = (duration/2) / 29.1;// convert the distance to centimeters. 126 | if (distance < 30)/*The distance that need to to keep with the wall */ { 127 | Serial.println ("Wall is ditected!" ); 128 | Serial.println (" Started following the wall "); 129 | Serial.println (" Turning !"); 130 | motorRight.setSpeed(vel); 131 | motorLeft.setSpeed(0); 132 | motorRight.run(FORWARD); 133 | motorLeft.run(RELEASE); 134 | delay(500); // wait for a second 135 | } 136 | 137 | else { 138 | Serial.println ("No Wall detected. turning round"); 139 | delay (15); 140 | motorRight.setSpeed(0); 141 | motorLeft.setSpeed(vel); 142 | motorRight.run(RELEASE); 143 | motorLeft.run (FORWARD); 144 | 145 | } 146 | break; 147 | 148 | case 'b': 149 | //obstacle avoider robot 150 | 151 | motorRight.setSpeed(vel); //set the speed of the motors, between 0-255 152 | motorLeft.setSpeed (vel); 153 | 154 | long Aduration, Adistance; // start the scan 155 | digitalWrite(trigPin, LOW); 156 | delayMicroseconds(2); // delays are required for a succesful sensor operation. 157 | digitalWrite(trigPin, HIGH); 158 | 159 | delayMicroseconds(10); //this delay is required as well! 160 | digitalWrite(trigPin, LOW); 161 | Aduration = pulseIn(echoPin, HIGH); 162 | Adistance = (Aduration/2) / 29.1;// convert the distance to centimeters. 163 | if (Adistance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ { 164 | Serial.println ("Close Obstacle detected!" ); 165 | Serial.println ("Obstacle Details:"); 166 | Serial.print ("Distance From Robot is " ); 167 | Serial.print ( Adistance); 168 | Serial.print ( " CM!");// print out the distance in centimeters. 169 | 170 | Serial.println (" The obstacle is declared a threat due to close distance. "); 171 | Serial.println (" Turning !"); 172 | motorRight.setSpeed(vel); 173 | motorLeft.setSpeed(vel); 174 | motorLeft.run(BACKWARD); // Turn as long as there's an obstacle ahead. 175 | motorRight.run (FORWARD); 176 | 177 | } 178 | else { 179 | Serial.println ("No obstacle detected. going forward"); 180 | delay (15); 181 | motorRight.setSpeed(vel); 182 | motorLeft.setSpeed(vel); 183 | motorRight.run(FORWARD); //if there's no obstacle ahead, Go Forward! 184 | motorLeft.run(FORWARD); 185 | 186 | } 187 | break; 188 | } 189 | } 190 | 191 | //get bluetooth code received from serial port 192 | int check(){ 193 | if (Serial.available() > 0){// if there is valid data in the serial port 194 | dataIn = Serial.read();// stores data into a varialbe 195 | 196 | //check the code 197 | if (dataIn == 'F'){//Forward 198 | determinant = 'F'; 199 | } 200 | else if (dataIn == 'B'){//Backward 201 | determinant = 'B'; 202 | } 203 | else if (dataIn == 'L'){//Left 204 | determinant = 'L'; 205 | } 206 | else if (dataIn == 'R'){//Right 207 | determinant = 'R'; 208 | } 209 | else if (dataIn == 'I'){//Froward Right 210 | determinant = 'I'; 211 | } 212 | else if (dataIn == 'J'){//Backward Right 213 | determinant = 'J'; 214 | } 215 | else if (dataIn == 'G'){//Forward Left 216 | determinant = 'G'; 217 | } 218 | else if (dataIn == 'H'){//Backward Left 219 | determinant = 'H'; 220 | } 221 | else if (dataIn == 'S'){//Stop 222 | determinant = 'S'; 223 | } 224 | else if (dataIn == '0'){//Speed 0 225 | vel = 0; 226 | } 227 | else if (dataIn == '1'){//Speed 25 228 | vel = 25; 229 | } 230 | else if (dataIn == '2'){//Speed 50 231 | vel = 50; 232 | } 233 | else if (dataIn == '3'){//Speed 75 234 | vel = 75; 235 | } 236 | else if (dataIn == '4'){//Speed 100 237 | vel = 100; 238 | } 239 | else if (dataIn == '5'){//Speed 125 240 | vel = 125; 241 | } 242 | else if (dataIn == '6'){//Speed 150 243 | vel = 150; 244 | } 245 | else if (dataIn == '7'){//Speed 175 246 | vel = 175; 247 | } 248 | else if (dataIn == '8'){//Speed 200 249 | vel = 200; 250 | } 251 | else if (dataIn == '9'){//Speed 225 252 | vel = 225; 253 | } 254 | else if (dataIn == 'b'){//Extra On 255 | determinant = 'b'; 256 | } 257 | else if (dataIn == 'm'){//Extra On 258 | determinant = 'm'; 259 | } 260 | 261 | } 262 | return determinant; 263 | } 264 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 FRE4K_<\> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Obstacle Avoider Sketch.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #define trigPin 14 // define the pins of your sensor 5 | #define echoPin 15 6 | 7 | int vel = 255; // Speed of the robot 8 | 9 | //Objects 10 | AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm 11 | AF_DCMotor motorLeft(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm 12 | 13 | void setup() { 14 | Serial.begin(9600); // set up Serial library at 9600 bps 15 | 16 | pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves) 17 | pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves) 18 | 19 | //Initalization messages 20 | Serial.println(" Mr.robot"); 21 | Serial.println(" Reday for working!"); 22 | 23 | //turn off motors 24 | motorRight.setSpeed(0); 25 | motorLeft.setSpeed(0); 26 | motorRight.run(RELEASE); 27 | motorLeft.run(RELEASE); 28 | } 29 | 30 | void loop() { 31 | //obstacle avoider robot 32 | 33 | motorRight.setSpeed(vel); //set the speed of the motors, between 0-255 34 | motorLeft.setSpeed (vel); 35 | 36 | long duration, distance; // start the scan 37 | digitalWrite(trigPin, LOW); 38 | delayMicroseconds(2); // delays are required for a succesful sensor operation. 39 | digitalWrite(trigPin, HIGH); 40 | 41 | delayMicroseconds(10); //this delay is required as well! 42 | digitalWrite(trigPin, LOW); 43 | duration = pulseIn(echoPin, HIGH); 44 | distance = (duration/2) / 29.1;// convert the distance to centimeters. 45 | if (distance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ { 46 | Serial.println ("Close Obstacle detected!" ); 47 | Serial.println ("Obstacle Details:"); 48 | Serial.print ("Distance From Robot is " ); 49 | Serial.print ( distance); 50 | Serial.print ( " CM!");// print out the distance in centimeters. 51 | 52 | Serial.println (" The obstacle is declared a threat due to close distance. "); 53 | Serial.println (" Turning !"); 54 | motorRight.setSpeed(vel); 55 | motorLeft.setSpeed(vel); 56 | motorLeft.run(BACKWARD); // Turn as long as there's an obstacle ahead. 57 | motorRight.run (FORWARD); 58 | 59 | } 60 | else { 61 | Serial.println ("No obstacle detected. going forward"); 62 | delay (15); 63 | motorRight.setSpeed(vel); 64 | motorLeft.setSpeed(vel); 65 | motorRight.run(FORWARD); //if there's no obstacle ahead, Go Forward! 66 | motorLeft.run(FORWARD); 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # arduino-robot-beginer-guide 2 | This is a beginner's guide to making your arduino robot. Smart phone controlled,wall follower and obstacle avoiding robot.We can learn the use of different programs do for different functions,mainly a smart phone controlled robot with obstacle avoider, wall follower,and maze solver,or you can alzo make it for only a single function. 3 | 4 | -------------------------------------------------------------------------------- /Wall Follower Sketch.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #define trigPin 14 // define the pins of your sensor 5 | #define echoPin 15 6 | 7 | int vel = 255; // Speed of the robot 8 | 9 | //Objects 10 | AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm 11 | AF_DCMotor motorLeft(3, MOTOR12_64KHZ); // create motor #3, 64KHz pwm 12 | 13 | void setup() 14 | { 15 | Serial.begin(9600); // set up Serial library at 9600 bps 16 | 17 | pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves) 18 | pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves) 19 | 20 | //Initalization messages 21 | Serial.println(" Mr.robot"); 22 | Serial.println(" Reday for working!"); 23 | 24 | //turn off motors 25 | motorRight.setSpeed(0); 26 | motorLeft.setSpeed(0); 27 | motorRight.run(RELEASE); 28 | motorLeft.run(RELEASE); 29 | } 30 | 31 | void loop() 32 | { 33 | 34 | //for wall follower robot. 35 | motorRight.setSpeed(vel); //set the speed of the motors, between 0-255 36 | motorLeft.setSpeed(vel); 37 | 38 | long duration, distance; // start the scan 39 | digitalWrite(trigPin, LOW); 40 | delayMicroseconds(2); // delays are required for a succesful sensor operation. 41 | digitalWrite(trigPin, HIGH); 42 | 43 | delayMicroseconds(10); //this delay is required as well! 44 | digitalWrite(trigPin, LOW); 45 | duration = pulseIn(echoPin, HIGH); 46 | distance = (duration / 2) / 29.1;// convert the distance to centimeters. 47 | if (distance < 30)/*The distance that need to to keep with the wall */ 48 | { 49 | Serial.println("Wall is ditected!"); 50 | Serial.println(" Started following the wall "); 51 | Serial.println(" Turning !"); 52 | motorRight.setSpeed(vel); 53 | motorLeft.setSpeed(0); 54 | motorRight.run(FORWARD); 55 | motorLeft.run(RELEASE); 56 | delay(500); // wait for a second 57 | } 58 | 59 | else 60 | { 61 | Serial.println("No Wall detected. turning round"); 62 | delay(15); 63 | motorRight.setSpeed(0); 64 | motorLeft.setSpeed(vel); 65 | motorRight.run(RELEASE); 66 | motorLeft.run(FORWARD); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /guide.md: -------------------------------------------------------------------------------- 1 | Step 2: Making the Chassis 2 | 3 | ![drill](https://user-images.githubusercontent.com/67673221/120104672-579a5a80-c175-11eb-8069-d8e074c68037.JPG) 4 | 5 | 6 | 7 | Drill two holes for motor: 8 | 9 | ![5](https://user-images.githubusercontent.com/67673221/120104763-caa3d100-c175-11eb-9b43-f6ff7d8e210d.JPG) 10 | 11 | 12 | 13 | Connect two motors: 14 | 15 | 16 | 17 | Make three holes for caster wheel: 18 | 19 | 20 | 21 | ![7](https://user-images.githubusercontent.com/67673221/120104769-d42d3900-c175-11eb-96bd-df0b8a26b68c.JPG) 22 | 23 | 24 | 25 | 26 | 27 | 28 | Connect the caster wheel: 29 | 30 | 31 | ![8](https://user-images.githubusercontent.com/67673221/120104775-dd1e0a80-c175-11eb-9ed4-e891c671c032.JPG) 32 | 33 | 34 | 35 | Make two holes on either side of the box for connecting the motors and three holes on the bottom for connecting the caster wheel after measuring and marking the correct diameter. Then install the motors and the caster. 36 | 37 | Batteries 38 | 39 | 40 | ![0](https://user-images.githubusercontent.com/67673221/120104798-fa52d900-c175-11eb-814c-d962cfecb80f.JPG) 41 | 42 | 43 | 44 | Connecting the batteries. 45 | 46 | 47 | 48 | ![2 battery](https://user-images.githubusercontent.com/67673221/120104838-3ab25700-c176-11eb-909a-453e4f0c54e1.JPG) 49 | 50 | 51 | 52 | 53 | Connection diagram. 54 | 55 | 56 | 57 | 58 | ![++](https://user-images.githubusercontent.com/67673221/120104847-47cf4600-c176-11eb-9d56-a1d852610108.JPG) 59 | 60 | 61 | 62 | 63 | Mount two 9 volt batteries inside the box above the caster. Then wire them in parallel and connect a switch as shown in above diagram. 64 | 65 | 66 | 67 | 68 | 69 | 70 | Connecting the Arduino and Motor Shield 71 | 72 | Attach the motor shield above the Arduino. 73 | 74 | 75 | 76 | ![--](https://user-images.githubusercontent.com/67673221/120104887-6b928c00-c176-11eb-919a-f5438f7d3e7d.JPG) 77 | 78 | 79 | 80 | 81 | 82 | Connect the battery wires to the PWR terminals of motor shield. 83 | 84 | 85 | ![+-](https://user-images.githubusercontent.com/67673221/120105076-30dd2380-c177-11eb-8ecc-ed93f9f73256.JPG) 86 | 87 | 88 | 89 | 90 | 91 | Connect the motors to the motor shield. 92 | 93 | 94 | 95 | ![+-](https://user-images.githubusercontent.com/67673221/120105131-5b2ee100-c177-11eb-80f4-fe5416355f58.JPG) 96 | 97 | 98 | 99 | 100 | 101 | Remove the jumper from this port. 102 | 103 | 104 | 105 | ![-+](https://user-images.githubusercontent.com/67673221/120105137-65e97600-c177-11eb-92c2-bde3e5386820.JPG) 106 | 107 | 108 | 109 | 110 | Connect the motor shield above the Arduino and place it above the battery. Then connect the wires from the motors and battery to the motor shield. Check out the connection diagram before connecting, as it is very important. 111 | 112 | 113 | ![connn](https://user-images.githubusercontent.com/67673221/120105193-a5b05d80-c177-11eb-8191-6b242c8d520d.JPG) 114 | 115 | 116 | 117 | 118 | Wiring Instructions: 119 | 120 | Connect the left motor to "M1" of motor shield 121 | Connect the right motor to "M3" of motor shield 122 | Connect the the wire from battery to "ext pwr" of motor shield 123 | Don't forget to remove the jumper from the "pwr" of motor shield 124 | 125 | 126 | 127 | ![connnn](https://user-images.githubusercontent.com/67673221/120105301-15bee380-c178-11eb-98b5-69501b6c9ddf.JPG) 128 | 129 | 130 | 131 | 132 | ![image](https://user-images.githubusercontent.com/67673221/120105366-53237100-c178-11eb-966a-ca487bb15bff.png) 133 | 134 | 135 | 136 | 137 | 138 | 139 | ![+--](https://user-images.githubusercontent.com/67673221/120105471-c62ce780-c178-11eb-9c9b-6695f069822e.JPG) 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | Make two holes for accessing the USB port and the DC input port of the Arduino. 150 | Take another 9 volt battery and connect a battery clip to a DC male jack adapter, then connect the DC male jack to the Arduino DC input port, to power the Arduino. 151 | Then place the battery between the motors and Arduino inside the box. 152 | 153 | Connecting Bluetooth Module and Switch 154 | 155 | 156 | 157 | ![ffffff](https://user-images.githubusercontent.com/67673221/120105592-49e6d400-c179-11eb-945c-1ed506a2703e.JPG) 158 | 159 | 160 | 161 | 162 | ![kkkk](https://user-images.githubusercontent.com/67673221/120105615-6420b200-c179-11eb-8dfc-ce045bdbed0f.JPG) 163 | 164 | 165 | 166 | 167 | 168 | ![--++](https://user-images.githubusercontent.com/67673221/120105663-a649f380-c179-11eb-8c9a-b2a674aea24f.JPG) 169 | 170 | 171 | 172 | 173 | 174 | 175 | Connect the Bluetooth module to the Arduino as shown in the connection diagram and place it inside the box. 176 | Then make hole to mount the switch on the back side of the box and connect the switch (here I have changed the switch which is used earlier because of some soldering problem). 177 | 178 | Wiring Instruction of Bluetooth module: 179 | 180 | "TX" of Bluetooth Module goes to "RX" of Arduino 181 | "RX" of Bluetooth Module goes to "TX" of Arduino 182 | "VCC" of Bluetooth Module goes to "5v" of Arduino 183 | "GND" of Bluetooth Module goes to "GND" of Arduino 184 | The State & Key pins of the BT modules are kept unused. 185 | 186 | Sensor Ultrasonic Mounting 187 | 188 | 189 | 190 | ![sensor](https://user-images.githubusercontent.com/67673221/120105817-49027200-c17a-11eb-8cfe-e9ca8025ccb2.JPG) 191 | 192 | 193 | 194 | 195 | ![connect](https://user-images.githubusercontent.com/67673221/120105840-63d4e680-c17a-11eb-85e1-fb8d9dc0a60f.JPG) 196 | 197 | 198 | 199 | 200 | 201 | ![conn wiire](https://user-images.githubusercontent.com/67673221/120105939-b31b1700-c17a-11eb-9829-94f8c06552ca.JPG) 202 | 203 | 204 | 205 | 206 | 207 | ![total](https://user-images.githubusercontent.com/67673221/120105948-bf06d900-c17a-11eb-8b39-f1a968ec441c.JPG) 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | Take the ultrasonic sensor and glue a small 'L' shaped plastic piece to it and glue it on top of the plastic box (or if you don't have a glue stick use double sided tape). 217 | Then connect the jumper wires to as shown in the circuit diagram above. 218 | 219 | Wiring Instruction of ultrasonic sensor: 220 | 221 | "VCC" of Ultra sonic sensor goes to "+5" of Arduino 222 | "GND" of Ultra sonic sensor goes to "GND" of Arduino 223 | "Trig" pin of Ultra sonic sensor goes to "Analog pin 1" of Arduino 224 | "Echo" pin of Ultra sonic sensor goes to "Analog pin 0" of Arduino 225 | Now we finished the all the connections and it's time to program. 226 | 227 | Last step - Arduino codes and Bluetooth app editing 228 | Upload the "Final Sketch" provided in the code section. If you face any error, make sure you have installed the AFmotor library. 229 | 230 | Now, we learned how to program a Arduino easily. I have shown here some programs to work this robot as a obstacle avoiding robot, Wall follower, and Bluetooth controlled. and at last i have combined this three functions together. Watch the video for more details and information 231 | 232 | Make sure to install AFmotor library into Arduino. 233 | Download AFmotor library:https://github.com/adafruit/Adafruit-Motor-Shield-library 234 | To install Arduino library:https://www.arduino.cc/en/Guide/Libraries 235 | --------------------------------------------------------------------------------