Components and supplies
Ceramic Disc Capacitor, 22 pF
Pin header 1x5 Female
Buzzer
Resistor 10k ohm
16 pin dip socket
Capacitor 10 µF
Dual H-Bridge motor drivers L293D
ATmega328
HC-06 Bluetooth Module
28 pin dip socket
Arduino USB 2 Serial micro
Pin header 1x40 Male
16 MHz Crystal
screw terminal 2P 2.54mm
Tools and machines
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Solder Wire, Lead Free
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
Arduino Bluetooth Car
c_cpp
1/* Arduino Bluetooth Car<br> * Created by Vasilakis Michalis // updated: 31/7/2019 2 * More information at www.ardumotive.com 3 */ 4#include 5//Software serial connection for bt module 6SoftwareSerial btSerial(A2,A3); // RX & TX 7 8//L293 Connection 9const int motorA1 = 5; // Pin 2 of L293 10const int motorA2 = 3; // Pin 7 of L293 11const int motorB1 = 11; // Pin 10 of L293 12const int motorB2 = 10; // Pin 14 of L293 13//Leds connected to Arduino UNO Pin 12 14const int front_lights = 8; 15const int back_lights = 7; 16//Buzzer / Speaker to Arduino UNO Pin 3 17const int buzzer = 2 ; 18 19//Useful Variables 20int i=0; 21int j=0; 22char state; 23 24void setup() { 25 // Initialize serial communication at 9600 bits per second: 26 btSerial.begin(9600); 27 Serial.begin(9600); // Only for debugging 28 // Set pins as outputs: 29 pinMode(motorA1, OUTPUT); 30 pinMode(motorA2, OUTPUT); 31 pinMode(motorB1, OUTPUT); 32 pinMode(motorB2, OUTPUT); 33 pinMode(front_lights, OUTPUT); 34 pinMode(back_lights, OUTPUT); 35 delay(500); 36 //Stop all motors 37 digitalWrite(motorA1, LOW); 38 digitalWrite(motorA2, LOW); 39 digitalWrite(motorB1, LOW); 40 digitalWrite(motorB2, LOW); 41} 42 43void loop() { 44 //Save income data to variable 'state' 45 if(btSerial.available() > 0){ 46 state = btSerial.read(); 47 Serial.println(state); 48 } 49 /***********************Forward****************************/ 50 //If state is equal with letter 'F', car will go forward! 51 if (state == 'F') { 52 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 53 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 54 Serial.println("Moving Forward"); 55 } 56 /**********************Forward Left************************/ 57 //If state is equal with letter 'G', car will go forward left 58 else if (state == 'G') { 59 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 60 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 61 Serial.println("Moving Forward Left"); 62 } 63 /**********************Forward Right************************/ 64 //If state is equal with letter 'I', car will go forward right 65 else if (state == 'I') { 66 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 67 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 68 Serial.println("Moving Forward Right"); 69 } 70 /***********************Backward****************************/ 71 //If state is equal with letter 'B', car will go backward 72 else if (state == 'B') { 73 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 74 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 75 Serial.println("Moving Backward"); 76 } 77 /**********************Backward Left************************/ 78 //If state is equal with letter 'H', car will go backward left 79 else if (state == 'H') { 80 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 81 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 82 Serial.println("Moving Backward Left"); 83 } 84 /**********************Backward Right************************/ 85 //If state is equal with letter 'J', car will go backward right 86 else if (state == 'J') { 87 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 88 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 89 Serial.println("Moving Backward Right"); 90 } 91 /***************************Left*****************************/ 92 //If state is equal with letter 'L', wheels will turn left 93 else if (state == 'L') { 94 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 95 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 96 Serial.println("Turn Left"); 97 } 98 /***************************Right*****************************/ 99 //If state is equal with letter 'R', wheels will turn right 100 else if (state == 'R') { 101 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 102 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 103 Serial.println("Turn Right"); 104 } 105 /************************Lights*****************************/ 106 //If state is equal with letter 'W/w', turn front leds on or of off 107 else if (state == 'W') { 108 digitalWrite(front_lights, HIGH); 109 Serial.println("Turning front lights ON"); 110 } 111 else if (state == 'w') { 112 digitalWrite(front_lights, LOW); 113 Serial.println("Turning front lights OFF"); 114 } 115 /************************Lights*****************************/ 116 //If state is equal with letter 'U/u', turn back leds on or of off 117 else if (state == 'U') { 118 digitalWrite(back_lights, HIGH); 119 Serial.println("Turning rear lights ON"); 120 } 121 else if (state == 'u') { 122 digitalWrite(back_lights, LOW); 123 Serial.println("Turning rear lights OFF"); 124 } 125 /**********************Horn sound***************************/ 126 //If state is equal with letter 'V', play (or stop) horn sound 127 else if (state == 'V'){ 128 tone(buzzer,500); 129 Serial.println("Playing horn sound"); 130 } 131 else if (state == 'v'){ 132 noTone(buzzer); 133 Serial.println("Stop playing horn sound"); 134 } 135 /************************Stop*****************************/ 136 //If state is equal with letter 'S', stop the car 137 else if (state == 'S'){ 138 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 139 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 140 Serial.println("STOP"); 141 } 142}
Arduino Bluetooth Car
c_cpp
1/* Arduino Bluetooth Car<br> * Created by Vasilakis Michalis // updated: 31/7/2019 2 * More information at www.ardumotive.com 3 */ 4#include 5//Software serial connection for bt module 6SoftwareSerial btSerial(A2,A3); // RX & TX 7 8//L293 Connection 9const int motorA1 = 5; // Pin 2 of L293 10const int motorA2 = 3; // Pin 7 of L293 11const int motorB1 = 11; // Pin 10 of L293 12const int motorB2 = 10; // Pin 14 of L293 13//Leds connected to Arduino UNO Pin 12 14const int front_lights = 8; 15const int back_lights = 7; 16//Buzzer / Speaker to Arduino UNO Pin 3 17const int buzzer = 2 ; 18 19//Useful Variables 20int i=0; 21int j=0; 22char state; 23 24void setup() { 25 // Initialize serial communication at 9600 bits per second: 26 btSerial.begin(9600); 27 Serial.begin(9600); // Only for debugging 28 // Set pins as outputs: 29 pinMode(motorA1, OUTPUT); 30 pinMode(motorA2, OUTPUT); 31 pinMode(motorB1, OUTPUT); 32 pinMode(motorB2, OUTPUT); 33 pinMode(front_lights, OUTPUT); 34 pinMode(back_lights, OUTPUT); 35 delay(500); 36 //Stop all motors 37 digitalWrite(motorA1, LOW); 38 digitalWrite(motorA2, LOW); 39 digitalWrite(motorB1, LOW); 40 digitalWrite(motorB2, LOW); 41} 42 43void loop() { 44 //Save income data to variable 'state' 45 if(btSerial.available() > 0){ 46 state = btSerial.read(); 47 Serial.println(state); 48 } 49 /***********************Forward****************************/ 50 //If state is equal with letter 'F', car will go forward! 51 if (state == 'F') { 52 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 53 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 54 Serial.println("Moving Forward"); 55 } 56 /**********************Forward Left************************/ 57 //If state is equal with letter 'G', car will go forward left 58 else if (state == 'G') { 59 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 60 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 61 Serial.println("Moving Forward Left"); 62 } 63 /**********************Forward Right************************/ 64 //If state is equal with letter 'I', car will go forward right 65 else if (state == 'I') { 66 digitalWrite(motorA1, HIGH); digitalWrite(motorA2, 0); 67 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 68 Serial.println("Moving Forward Right"); 69 } 70 /***********************Backward****************************/ 71 //If state is equal with letter 'B', car will go backward 72 else if (state == 'B') { 73 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 74 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 75 Serial.println("Moving Backward"); 76 } 77 /**********************Backward Left************************/ 78 //If state is equal with letter 'H', car will go backward left 79 else if (state == 'H') { 80 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 81 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 82 Serial.println("Moving Backward Left"); 83 } 84 /**********************Backward Right************************/ 85 //If state is equal with letter 'J', car will go backward right 86 else if (state == 'J') { 87 digitalWrite(motorA1, 0); digitalWrite(motorA2, HIGH); 88 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 89 Serial.println("Moving Backward Right"); 90 } 91 /***************************Left*****************************/ 92 //If state is equal with letter 'L', wheels will turn left 93 else if (state == 'L') { 94 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 95 digitalWrite(motorB1, HIGH); digitalWrite(motorB2, 0); 96 Serial.println("Turn Left"); 97 } 98 /***************************Right*****************************/ 99 //If state is equal with letter 'R', wheels will turn right 100 else if (state == 'R') { 101 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 102 digitalWrite(motorB1, 0); digitalWrite(motorB2, HIGH); 103 Serial.println("Turn Right"); 104 } 105 /************************Lights*****************************/ 106 //If state is equal with letter 'W/w', turn front leds on or of off 107 else if (state == 'W') { 108 digitalWrite(front_lights, HIGH); 109 Serial.println("Turning front lights ON"); 110 } 111 else if (state == 'w') { 112 digitalWrite(front_lights, LOW); 113 Serial.println("Turning front lights OFF"); 114 } 115 /************************Lights*****************************/ 116 //If state is equal with letter 'U/u', turn back leds on or of off 117 else if (state == 'U') { 118 digitalWrite(back_lights, HIGH); 119 Serial.println("Turning rear lights ON"); 120 } 121 else if (state == 'u') { 122 digitalWrite(back_lights, LOW); 123 Serial.println("Turning rear lights OFF"); 124 } 125 /**********************Horn sound***************************/ 126 //If state is equal with letter 'V', play (or stop) horn sound 127 else if (state == 'V'){ 128 tone(buzzer,500); 129 Serial.println("Playing horn sound"); 130 } 131 else if (state == 'v'){ 132 noTone(buzzer); 133 Serial.println("Stop playing horn sound"); 134 } 135 /************************Stop*****************************/ 136 //If state is equal with letter 'S', stop the car 137 else if (state == 'S'){ 138 digitalWrite(motorA1, 0); digitalWrite(motorA2, 0); 139 digitalWrite(motorB1, 0); digitalWrite(motorB2, 0); 140 Serial.println("STOP"); 141 } 142}
Downloadable files
PCB Schematic
Order it from pcbway.com and get 10pcs PCB for free! Instructions on how to order it can be found in the video that we have in first step. You can also make your changes here: https://easyeda.com/mi.vasilakis/My_PCB-9fb30c4a0c7e459cb9484f305015f0c8
PCB Schematic
PCB Schematic
Order it from pcbway.com and get 10pcs PCB for free! Instructions on how to order it can be found in the video that we have in first step. You can also make your changes here: https://easyeda.com/mi.vasilakis/My_PCB-9fb30c4a0c7e459cb9484f305015f0c8
PCB Schematic
Circuit Schematic
Circuit Schematic
Comments
Only logged in users can leave comments
ardumotive
0 Followers
•0 Projects
Table of contents
Intro
8
0