Components and supplies
9V Battery Clip
Dual H-Bridge motor drivers L298
SparkFun Bluetooth Modem - BlueSMiRF Silver
Solid V Wheel Kit
Arduino UNO
Wire Cable - By the Foot
DC motor (generic)
9V battery (generic)
Apps and platforms
bluetoothchat
Project description
Code
CarritomasTAB.ino
c_cpp
1//Update No.: 2 ( Beta Version) original version issued: August_29_2016 2//Developed by : Hernando Bolaos 3//*********************************************************************************************************************************************** 4//Disclaim Note: 5//THIS SOFTWARE IS PROVIDED BY THE DEVELOPER "AS IS" AND ANY EXPRESSED OR 6//IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 7//OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 8//IN NO EVENT SHALL THE DEVELOPER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 9//INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 10//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 11//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 12//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 13//STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 14//IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 15//THE POSSIBILITY OF SUCH DAMAGE. 16//************************************************************************************************************************************************* 17 18 19 20 21const int ENB = 3; 22const int IN4 = 5; 23const int IN3 = 6; 24const int ENA = 11; 25const int IN2 = 9; 26const int IN1 = 10; 27 28 29 30byte speed = 0; 31char data=0; 32 33 34void setup() { 35 pinMode(ENB, OUTPUT); //Set digital output PWM as motor 1 speed value 36 pinMode(IN4, OUTPUT); //Set digital otuput PWM as motor 1 direction A 37 pinMode(IN3, OUTPUT); //Set digital ouput PWM as motor 1 direction B 38 pinMode(ENA, OUTPUT); //Set digital output PWM as motor 2 speed value 39 pinMode(IN2, OUTPUT); //Set digital output PWM as motor 2 direction B 40 pinMode(IN1, OUTPUT); //Set digital output PWM as motor 2 direction A 41 42 Serial.begin(9600); //Sets the baud for serial data transmission 43} 44 45 void loop() { 46 47if(Serial.available() > 0) // Send data only when you receive data: 48 49 { 50 data = Serial.read(); //Read the incoming data & store into data 51 Serial.print(data); //Print Value inside data in Serial monitor 52 Serial.print("\ 53"); 54 delay(200); 55 56 57 if(data == 'F') { // Checks whether value of data is equal to 1 - it works as pulse and latching 58 59 Serial.println(" Forward command Received on Bluetooth - F !!! "); //Send message to serial 60 forward(); 61 delay(100); 62 63 64 65 } 66 67 68 if(data == 'B') { // Checks whether value of data is equal to B - it works as pulse and latching 69 70 Serial.println(" Backward Command received on Bluetooth - B !!! "); //Send message to serial 71 72 backward(); 73 delay(100); 74 75 76 77 78 } 79 80 81 82 if(data == 'S') { // Checks whether value of data is equal to S - it works as pulse and latching 83 84 85 86 Serial.println(" Stop command received on Bluetooth - S !!! "); 87 pare(); 88 delay(100); 89 90 91 } 92 93 if(data == 'L') { // Checks whether value of data is equal to L - it works as pulse and latching 94 95 96 97 Serial.println(" Left command Received on Bluetooth - L !!! "); 98 leftF(); 99 delay(2000); 100 forward(); 101 102 103 } 104 105 if(data == 'R') { // Checks whether value of data is equal to R - funciona como pulso 106 107 108 109 Serial.println(" Right command received on Bluetooth - R !!! ");//Send message to serial 110 rightF(); 111 delay(2000); 112 forward(); 113 114 115 } 116 117 if(data == 'X') { // Checks whether value of data is equal to R - it works as pulse and latching 118 119 120 121 Serial.println(" Left command received on Bluetooth - R !!! ");//Send message to serial 122 leftB(); 123 delay(2000); 124 backward(); 125 126 127 } 128 129 if(data == 'Y') { // Checks whether value of data is equal to R - it works as pulse and latching 130 131 132 133 Serial.println(" Right command received on Bluetooth - R !!! ");//Send message to serial 134 rightB(); 135 delay(2000); 136 backward(); 137 138 139 } 140 141 142 143 144 if(data == 'V') { // Checks whether value of data is equal to R - funciona como pulso 145 146 147 148 Serial.println(" Vmin received on Bluetooth - V !!! ");//Send message to serial 149 speed = 80; // Sets Vmin output = 80 150 151 152 } 153 154 155 if(data == 'W') { // Checks whether value of data is equal to R - funciona como pulso 156 157 158 159 Serial.println(" Vmed received on Bluetooth -W !!! ");//Send message to serial 160 speed = 128;// Sets Vmed output = 128 161 162 163 } 164 165 166 167 if(data == 'Z') { // Checks whether value of data is equal to R - funciona como pulso 168 169 170 171 Serial.println(" Vmax received on Bluetooth - Z !!! ");//Send message to serial 172 speed = 255;// Sets Vmax output = 255 173 174 175 } 176 177 } 178 179 180 181 182} 183 184void backward() { //Backward routine 185 186 digitalWrite (IN1, HIGH); 187 digitalWrite (IN2, LOW); 188 digitalWrite (IN3, HIGH); 189 digitalWrite (IN4, LOW); 190 191analogWrite(ENA, speed); 192analogWrite(ENB, speed); 193 194 195} 196 197void forward() { //Forward routine 198 digitalWrite (IN1, LOW); 199 digitalWrite (IN2, HIGH); 200 digitalWrite (IN3, LOW); 201 digitalWrite (IN4, HIGH); 202 203analogWrite(ENA, speed); 204analogWrite(ENB, speed); 205 206} 207 208 209void pare() { //Stop 210 analogWrite(ENA, 0); 211 analogWrite(ENB, 0); 212 213} 214 215 216void leftF() { //Left going Forward routine 217digitalWrite (IN1, LOW); 218 digitalWrite (IN2, HIGH); 219 digitalWrite (IN3, LOW); 220 digitalWrite (IN4, HIGH); 221 222analogWrite(ENA, speed); 223analogWrite(ENB, 0); 224} 225 226 227void rightF() { //Right going forward routine 228digitalWrite (IN1, LOW); 229 digitalWrite (IN2, HIGH); 230 digitalWrite (IN3, LOW); 231 digitalWrite (IN4, HIGH); 232 233analogWrite(ENA, 0); 234analogWrite(ENB, speed); 235} 236 237 238void leftB() { //Left going backward routine 239digitalWrite (IN1, HIGH); 240 digitalWrite (IN2, LOW); 241 digitalWrite (IN3, HIGH); 242 digitalWrite (IN4, LOW); 243 244analogWrite(ENA, speed); 245analogWrite(ENB, 0); 246} 247 248 249void rightB() { //Right going backward routine 250 digitalWrite (IN1, HIGH); 251 digitalWrite (IN2, LOW); 252 digitalWrite (IN3, HIGH); 253 digitalWrite (IN4, LOW); 254 255analogWrite(ENA, 0); 256analogWrite(ENB, speed); 257} 258 259 260
CarritomasTAB.ino
c_cpp
1//Update No.: 2 ( Beta Version) original version issued: August_29_2016 2//Developed by : Hernando Bolaos 3//*********************************************************************************************************************************************** 4//Disclaim Note: 5//THIS SOFTWARE IS PROVIDED BY THE DEVELOPER "AS IS" AND ANY EXPRESSED OR 6//IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 7//OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 8//IN NO EVENT SHALL THE DEVELOPER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 9//INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 10//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 11//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 12//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 13//STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 14//IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 15//THE POSSIBILITY OF SUCH DAMAGE. 16//************************************************************************************************************************************************* 17 18 19 20 21const int ENB = 3; 22const int IN4 = 5; 23const int IN3 = 6; 24const int ENA = 11; 25const int IN2 = 9; 26const int IN1 = 10; 27 28 29 30byte speed = 0; 31char data=0; 32 33 34void setup() { 35 pinMode(ENB, OUTPUT); //Set digital output PWM as motor 1 speed value 36 pinMode(IN4, OUTPUT); //Set digital otuput PWM as motor 1 direction A 37 pinMode(IN3, OUTPUT); //Set digital ouput PWM as motor 1 direction B 38 pinMode(ENA, OUTPUT); //Set digital output PWM as motor 2 speed value 39 pinMode(IN2, OUTPUT); //Set digital output PWM as motor 2 direction B 40 pinMode(IN1, OUTPUT); //Set digital output PWM as motor 2 direction A 41 42 Serial.begin(9600); //Sets the baud for serial data transmission 43} 44 45 void loop() { 46 47if(Serial.available() > 0) // Send data only when you receive data: 48 49 { 50 data = Serial.read(); //Read the incoming data & store into data 51 Serial.print(data); //Print Value inside data in Serial monitor 52 Serial.print("\ 53"); 54 delay(200); 55 56 57 if(data == 'F') { // Checks whether value of data is equal to 1 - it works as pulse and latching 58 59 Serial.println(" Forward command Received on Bluetooth - F !!! "); //Send message to serial 60 forward(); 61 delay(100); 62 63 64 65 } 66 67 68 if(data == 'B') { // Checks whether value of data is equal to B - it works as pulse and latching 69 70 Serial.println(" Backward Command received on Bluetooth - B !!! "); //Send message to serial 71 72 backward(); 73 delay(100); 74 75 76 77 78 } 79 80 81 82 if(data == 'S') { // Checks whether value of data is equal to S - it works as pulse and latching 83 84 85 86 Serial.println(" Stop command received on Bluetooth - S !!! "); 87 pare(); 88 delay(100); 89 90 91 } 92 93 if(data == 'L') { // Checks whether value of data is equal to L - it works as pulse and latching 94 95 96 97 Serial.println(" Left command Received on Bluetooth - L !!! "); 98 leftF(); 99 delay(2000); 100 forward(); 101 102 103 } 104 105 if(data == 'R') { // Checks whether value of data is equal to R - funciona como pulso 106 107 108 109 Serial.println(" Right command received on Bluetooth - R !!! ");//Send message to serial 110 rightF(); 111 delay(2000); 112 forward(); 113 114 115 } 116 117 if(data == 'X') { // Checks whether value of data is equal to R - it works as pulse and latching 118 119 120 121 Serial.println(" Left command received on Bluetooth - R !!! ");//Send message to serial 122 leftB(); 123 delay(2000); 124 backward(); 125 126 127 } 128 129 if(data == 'Y') { // Checks whether value of data is equal to R - it works as pulse and latching 130 131 132 133 Serial.println(" Right command received on Bluetooth - R !!! ");//Send message to serial 134 rightB(); 135 delay(2000); 136 backward(); 137 138 139 } 140 141 142 143 144 if(data == 'V') { // Checks whether value of data is equal to R - funciona como pulso 145 146 147 148 Serial.println(" Vmin received on Bluetooth - V !!! ");//Send message to serial 149 speed = 80; // Sets Vmin output = 80 150 151 152 } 153 154 155 if(data == 'W') { // Checks whether value of data is equal to R - funciona como pulso 156 157 158 159 Serial.println(" Vmed received on Bluetooth -W !!! ");//Send message to serial 160 speed = 128;// Sets Vmed output = 128 161 162 163 } 164 165 166 167 if(data == 'Z') { // Checks whether value of data is equal to R - funciona como pulso 168 169 170 171 Serial.println(" Vmax received on Bluetooth - Z !!! ");//Send message to serial 172 speed = 255;// Sets Vmax output = 255 173 174 175 } 176 177 } 178 179 180 181 182} 183 184void backward() { //Backward routine 185 186 digitalWrite (IN1, HIGH); 187 digitalWrite (IN2, LOW); 188 digitalWrite (IN3, HIGH); 189 digitalWrite (IN4, LOW); 190 191analogWrite(ENA, speed); 192analogWrite(ENB, speed); 193 194 195} 196 197void forward() { //Forward routine 198 digitalWrite (IN1, LOW); 199 digitalWrite (IN2, HIGH); 200 digitalWrite (IN3, LOW); 201 digitalWrite (IN4, HIGH); 202 203analogWrite(ENA, speed); 204analogWrite(ENB, speed); 205 206} 207 208 209void pare() { //Stop 210 analogWrite(ENA, 0); 211 analogWrite(ENB, 0); 212 213} 214 215 216void leftF() { //Left going Forward routine 217digitalWrite (IN1, LOW); 218 digitalWrite (IN2, HIGH); 219 digitalWrite (IN3, LOW); 220 digitalWrite (IN4, HIGH); 221 222analogWrite(ENA, speed); 223analogWrite(ENB, 0); 224} 225 226 227void rightF() { //Right going forward routine 228digitalWrite (IN1, LOW); 229 digitalWrite (IN2, HIGH); 230 digitalWrite (IN3, LOW); 231 digitalWrite (IN4, HIGH); 232 233analogWrite(ENA, 0); 234analogWrite(ENB, speed); 235} 236 237 238void leftB() { //Left going backward routine 239digitalWrite (IN1, HIGH); 240 digitalWrite (IN2, LOW); 241 digitalWrite (IN3, HIGH); 242 digitalWrite (IN4, LOW); 243 244analogWrite(ENA, speed); 245analogWrite(ENB, 0); 246} 247 248 249void rightB() { //Right going backward routine 250 digitalWrite (IN1, HIGH); 251 digitalWrite (IN2, LOW); 252 digitalWrite (IN3, HIGH); 253 digitalWrite (IN4, LOW); 254 255analogWrite(ENA, 0); 256analogWrite(ENB, speed); 257} 258 259 260
Downloadable files
carritomasTABSchem_schem.png
carritomasTABSchem_schem.png
carritomasTABSchem_bb.jpg
carritomasTABSchem_bb.jpg
carritomasTABSchem_schem.png
carritomasTABSchem_schem.png
Comments
Only logged in users can leave comments