Devices & Components
HC-05 Bluetooth Module
UTSOURCE Electronic Parts
Dual H-Bridge motor drivers L293D
Dual H-Bridge motor drivers L298
Arduino Pro Mini 328 - 5V/16MHz
Hardware & Tools
Hot glue gun (generic)
Software & Tools
arduino rc car
Arduino IDE
Project description
Code
Code
c_cpp
1/****LulBot***/ 2 3/* Arduino Rolling robot 4 * by Ashraf Minhaj 5 6 * mail me at ashraf_minhaj@yahoo.com 7 * tutorial- ashrafminhajfb.blogspot.com 8 9 */ 10 11//Declare the arduino pins 12 13int lm1 = 10; //declare 1st motor pins 14int 15 lm2 = 9; 16 17int rm1 = 8; //right motor pins 18int rm2 = 7; 19 20 21void 22 setup() 23{ 24 //initlize the mode of the pins 25 pinMode(lm1,OUTPUT); 26 27 pinMode(lm2,OUTPUT); 28 pinMode(rm1,OUTPUT); 29 pinMode(rm2,OUTPUT); 30 31 32 //set the serial communication rate 33 Serial.begin(9600); 34} 35 36void 37 loop() 38{ 39 //check whether arduino is reciving signal or not 40 while(Serial.available() 41 == 0); 42 char val = Serial.read() ;//reads the signal 43 Serial.print(val); 44 45 46 /*********For Forward motion*********/ 47 48 if (val == 'F') 49 { 50 Serial.println("FORWARD"); 51 52 digitalWrite(lm1,HIGH); 53 digitalWrite(rm1,HIGH); 54 digitalWrite(lm2,LOW); 55 56 digitalWrite(rm2,LOW); 57 58 } 59 60 61 /*********For 62 Backward Motion*********/ 63 else if(val == 'B') 64 { 65 Serial.println("BACK"); 66 67 digitalWrite(lm2,HIGH); 68 digitalWrite(rm2,HIGH); 69 digitalWrite(lm1,LOW); 70 71 digitalWrite(rm1,LOW); 72 73 } 74 /*********Right*********/ 75 76 else if(val == 'R') 77 { 78 Serial.println("RIGHT"); 79 digitalWrite(lm1,HIGH); 80 81 digitalWrite(rm2,HIGH); 82 digitalWrite(lm2,LOW); 83 digitalWrite(rm1,LOW); 84 85 } 86 /*********Left*********/ 87 else if(val == 'L') 88 { 89 Serial.println("LEFT"); 90 91 digitalWrite(lm2,HIGH); 92 digitalWrite(rm1,HIGH); 93 digitalWrite(lm1,LOW); 94 95 digitalWrite(rm2,LOW); 96 97 } 98 99 100 /*********STOP*********/ 101 102 else 103 { 104 Serial.println("No data or Invalid!!!"); 105 digitalWrite(lm1,LOW); 106 107 digitalWrite(rm1,LOW); 108 digitalWrite(lm2,LOW); 109 digitalWrite(rm2,LOW); 110 111 112 } 113 114} 115
Code
c_cpp
1/****LulBot***/ 2 3/* Arduino Rolling robot 4 * by Ashraf Minhaj 5 * mail me at ashraf_minhaj@yahoo.com 6 * tutorial- ashrafminhajfb.blogspot.com 7 */ 8 9//Declare the arduino pins 10 11int lm1 = 10; //declare 1st motor pins 12int lm2 = 9; 13 14int rm1 = 8; //right motor pins 15int rm2 = 7; 16 17 18void setup() 19{ 20 //initlize the mode of the pins 21 pinMode(lm1,OUTPUT); 22 pinMode(lm2,OUTPUT); 23 pinMode(rm1,OUTPUT); 24 pinMode(rm2,OUTPUT); 25 26 //set the serial communication rate 27 Serial.begin(9600); 28} 29 30void loop() 31{ 32 //check whether arduino is reciving signal or not 33 while(Serial.available() == 0); 34 char val = Serial.read() ;//reads the signal 35 Serial.print(val); 36 37 /*********For Forward motion*********/ 38 39 if (val == 'F') 40 { 41 Serial.println("FORWARD"); 42 digitalWrite(lm1,HIGH); 43 digitalWrite(rm1,HIGH); 44 digitalWrite(lm2,LOW); 45 digitalWrite(rm2,LOW); 46 47 } 48 49 50 /*********For Backward Motion*********/ 51 else if(val == 'B') 52 { 53 Serial.println("BACK"); 54 digitalWrite(lm2,HIGH); 55 digitalWrite(rm2,HIGH); 56 digitalWrite(lm1,LOW); 57 digitalWrite(rm1,LOW); 58 59 } 60 /*********Right*********/ 61 else if(val == 'R') 62 { 63 Serial.println("RIGHT"); 64 digitalWrite(lm1,HIGH); 65 digitalWrite(rm2,HIGH); 66 digitalWrite(lm2,LOW); 67 digitalWrite(rm1,LOW); 68 } 69 /*********Left*********/ 70 else if(val == 'L') 71 { 72 Serial.println("LEFT"); 73 digitalWrite(lm2,HIGH); 74 digitalWrite(rm1,HIGH); 75 digitalWrite(lm1,LOW); 76 digitalWrite(rm2,LOW); 77 78 } 79 80 81 /*********STOP*********/ 82 else 83 { 84 Serial.println("No data or Invalid!!!"); 85 digitalWrite(lm1,LOW); 86 digitalWrite(rm1,LOW); 87 digitalWrite(lm2,LOW); 88 digitalWrite(rm2,LOW); 89 90 } 91 92} 93
Downloadable files
Circuit Diagram
Circuit Diagram
circuit with l298n
circuit with l298n
Circuit Diagram
Circuit Diagram
circuit with l298n
circuit with l298n
more detailed circuit
https://github.com/ashraf-minhaj/LulaBot
Comments
Only logged in users can leave comments