Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
L293D Motor Drive Shield for Arduino Uno
HC-05 Bluetooth Module
12 V 200 rpm DC Motor
Breadboard (generic)
Software & Tools
Arduino IDE
Project description
Code
The code
c_cpp
This code has to uploaded on Arduino Uno
1#include <AFMotor.h> 2 3AF_DCMotor motor1(1); //motor1 is the left motor 4AF_DCMotor motor2(2); //motor2 is the right motor 5 6int val; 7void setup() 8{ 9 Serial.begin(9600); 10 11 motor1.setSpeed(255); //motor speed is set 12 motor2.setSpeed(255); 13 Stop(); 14} 15 16 17void loop() { 18 19bt=Serial.read(); 20 21if(val=='1') //when the bluetooth module recieves 1 the car moves forward 22{ 23 forward(); 24} 25 26if(val=='2') //when the bluetooth module recieves 2 the car moves backward 27{ 28 backward(); 29} 30 31if(val=='3') //when the bluetooth module recieves 3 the car moves left 32{ 33 left(); 34} 35 36if(val=='4') //when the bluetooth module recieves 4 the car moves right 37{ 38 right(); 39} 40 41if(val=='5') //when the bluetooth module recieves 5 the car stops 42{ 43 Stop(); 44} 45 46} 47void forward() 48{ 49 motor1.run(FORWARD); 50 motor2.run(FORWARD); 51} 52 53void backward() 54{ 55 motor1.run(BACKWARD); 56 motor2.run(BACKWARD); 57} 58void left() 59{ 60 motor1.run(BACKWARD); 61 motor2.run(FORWARD); 62} 63void right() 64{ 65 motor1.run(FORWARD); 66 motor2.run(BACKWARD); 67} 68void Stop() 69{ 70 motor1.run(RELEASE); 71 motor2.run(RELEASE); 72} 73
Downloadable files
The circuit
These are the connections. Connect 12v power source to the motor driver shield. Please note that the schematic does not include the external power source.
The circuit

The circuit
These are the connections. Connect 12v power source to the motor driver shield. Please note that the schematic does not include the external power source.
The circuit

Comments
Only logged in users can leave comments