Components and supplies
I2C 16x2 Arduino LCD Display Module
DC Motor, 12 V
Jumper wires (generic)
Dual H-Bridge motor drivers L298
Breadboard (generic)
Arduino UNO
Apps and platforms
Arduino IDE
Project description
Code
RC Car's Code
arduino
That's the code guys
1#include <LiquidCrystal_I2C.h> 2 3#include "SoftwareSerial.h"// import the serial library\\ 4 5const int IN1=3; 6const int IN2=5; 7const int IN3=6; 8const int IN4=9; 9 int BluetoothData; 10 SoftwareSerial HC05(10, 11); // RX, TX 11 LiquidCrystal_I2C lcd(0x27, 16, 2); 12 int SPEED_Control=200; 13void setup() { 14 // fIRST , define the Motor's pin as an OUTPUT 15lcd.begin(); 16lcd.backlight(); 17pinMode( IN1 ,OUTPUT);// Right Motor 1st wire 18pinMode( IN2 ,OUTPUT);// Right Motor 2nd wire 19pinMode( IN3 ,OUTPUT);// left Motor 1st wire 20pinMode( IN4 ,OUTPUT);// left Motor 2nd wire 21 HC05.begin(9600); 22 lcd.clear(); 23 lcd.print("Starting"); 24} 25void FORWARD(int Speed){ 26 //When we want to let Motor To Rotate clock wise 27 // just void this part on the loop section . 28 lcd.clear(); 29 lcd.print("FORWARD"); 30 analogWrite(IN1,0); 31 analogWrite(IN2,Speed); 32 analogWrite(IN3,Speed); 33 analogWrite(IN4,0); 34} 35void BACKWARD(int Speed){ 36 //When we want to let Motor To Rotate Counter clock wise 37 // just void this part on the loop section . 38 lcd.clear(); 39 lcd.print("BACKWARD"); 40 analogWrite(IN1,Speed); 41 analogWrite(IN2,0); 42 analogWrite(IN3,0); 43 analogWrite(IN4,Speed); 44} 45void LEFT(int Speed){ 46 //When we want to let Motor To Rotate Counter clock wise 47 // just void this part on the loop section . 48 lcd.clear(); 49 lcd.print("LEFT"); 50 analogWrite(IN1,0); 51 analogWrite(IN2,Speed); 52 analogWrite(IN3,0); 53 analogWrite(IN4,Speed); 54} 55void RIGHT(int Speed){ 56 //When we want to let Motor To Rotate Counter clock wise 57 // just void this part on the loop section . 58 lcd.clear(); 59 lcd.print("RIGHT"); 60 analogWrite(IN1,Speed); 61 analogWrite(IN2,0); 62 analogWrite(IN3,Speed); 63 analogWrite(IN4,0); 64} 65 66void Stop(){ 67 //When we want to let Motor To Rotate clock wise 68 // just void this part on the loop section . 69 analogWrite(IN1,0); 70 analogWrite(IN2,0); 71 analogWrite(IN3,0); 72 analogWrite(IN4,0); 73} 74 75void loop() { 76 //Rise Up 77 78 if (HC05.available()){ 79 BluetoothData=HC05.read(); 80 Serial.println(BluetoothData); 81 82 if(BluetoothData=='F'){ // if number 1 pressed .... 83 FORWARD(SPEED_Control); 84 } 85 if(BluetoothData=='B'){ // if number 1 pressed .... 86 BACKWARD(SPEED_Control); 87 } 88 if(BluetoothData=='L'){ // if number 1 pressed .... 89 RIGHT(SPEED_Control); 90 91 } 92 if(BluetoothData=='R'){ // if number 1 pressed .... 93 LEFT(SPEED_Control); 94 } 95 if(BluetoothData=='S'){ // if number 1 pressed .... 96 Stop(); 97 } 98 if(BluetoothData=='0'){ SPEED_Control=0 ;}//Speed 99 if(BluetoothData=='1'){ SPEED_Control=50; }//Speed 100 if(BluetoothData=='2'){ SPEED_Control=100; }//Speed 101 if(BluetoothData=='3'){ SPEED_Control=120; }//Speed 102 if(BluetoothData=='4'){ SPEED_Control=140; }//Speed 103 if(BluetoothData=='5'){ SPEED_Control=160; }//Speed 104 if(BluetoothData=='6'){ SPEED_Control=180; }//Speed 105 if(BluetoothData=='7'){ SPEED_Control=200; }//Speed 106 if(BluetoothData=='8'){ SPEED_Control=220; }//Speed 107 if(BluetoothData=='9'){ SPEED_Control=240; }//Speed 108 if(BluetoothData=='q'){ SPEED_Control=255; }//Speed 109 } 110} 111
LCD I2C Library
RC Car's Code
arduino
That's the code guys
1#include <LiquidCrystal_I2C.h> 2 3#include "SoftwareSerial.h"// import the serial library\\ 4 5const int IN1=3; 6const int IN2=5; 7const int IN3=6; 8const int IN4=9; 9 int BluetoothData; 10 SoftwareSerial HC05(10, 11); // RX, TX 11 LiquidCrystal_I2C lcd(0x27, 16, 2); 12 int SPEED_Control=200; 13void setup() { 14 // fIRST , define the Motor's pin as an OUTPUT 15lcd.begin(); 16lcd.backlight(); 17pinMode( IN1 ,OUTPUT);// Right Motor 1st wire 18pinMode( IN2 ,OUTPUT);// Right Motor 2nd wire 19pinMode( IN3 ,OUTPUT);// left Motor 1st wire 20pinMode( IN4 ,OUTPUT);// left Motor 2nd wire 21 HC05.begin(9600); 22 lcd.clear(); 23 lcd.print("Starting"); 24} 25void FORWARD(int Speed){ 26 //When we want to let Motor To Rotate clock wise 27 // just void this part on the loop section . 28 lcd.clear(); 29 lcd.print("FORWARD"); 30 analogWrite(IN1,0); 31 analogWrite(IN2,Speed); 32 analogWrite(IN3,Speed); 33 analogWrite(IN4,0); 34} 35void BACKWARD(int Speed){ 36 //When we want to let Motor To Rotate Counter clock wise 37 // just void this part on the loop section . 38 lcd.clear(); 39 lcd.print("BACKWARD"); 40 analogWrite(IN1,Speed); 41 analogWrite(IN2,0); 42 analogWrite(IN3,0); 43 analogWrite(IN4,Speed); 44} 45void LEFT(int Speed){ 46 //When we want to let Motor To Rotate Counter clock wise 47 // just void this part on the loop section . 48 lcd.clear(); 49 lcd.print("LEFT"); 50 analogWrite(IN1,0); 51 analogWrite(IN2,Speed); 52 analogWrite(IN3,0); 53 analogWrite(IN4,Speed); 54} 55void RIGHT(int Speed){ 56 //When we want to let Motor To Rotate Counter clock wise 57 // just void this part on the loop section . 58 lcd.clear(); 59 lcd.print("RIGHT"); 60 analogWrite(IN1,Speed); 61 analogWrite(IN2,0); 62 analogWrite(IN3,Speed); 63 analogWrite(IN4,0); 64} 65 66void Stop(){ 67 //When we want to let Motor To Rotate clock wise 68 // just void this part on the loop section . 69 analogWrite(IN1,0); 70 analogWrite(IN2,0); 71 analogWrite(IN3,0); 72 analogWrite(IN4,0); 73} 74 75void loop() { 76 //Rise Up 77 78 if (HC05.available()){ 79 BluetoothData=HC05.read(); 80 Serial.println(BluetoothData); 81 82 if(BluetoothData=='F'){ // if number 1 pressed .... 83 FORWARD(SPEED_Control); 84 } 85 if(BluetoothData=='B'){ // if number 1 pressed .... 86 BACKWARD(SPEED_Control); 87 } 88 if(BluetoothData=='L'){ // if number 1 pressed .... 89 RIGHT(SPEED_Control); 90 91 } 92 if(BluetoothData=='R'){ // if number 1 pressed .... 93 LEFT(SPEED_Control); 94 } 95 if(BluetoothData=='S'){ // if number 1 pressed .... 96 Stop(); 97 } 98 if(BluetoothData=='0'){ SPEED_Control=0 ;}//Speed 99 if(BluetoothData=='1'){ SPEED_Control=50; }//Speed 100 if(BluetoothData=='2'){ SPEED_Control=100; }//Speed 101 if(BluetoothData=='3'){ SPEED_Control=120; }//Speed 102 if(BluetoothData=='4'){ SPEED_Control=140; }//Speed 103 if(BluetoothData=='5'){ SPEED_Control=160; }//Speed 104 if(BluetoothData=='6'){ SPEED_Control=180; }//Speed 105 if(BluetoothData=='7'){ SPEED_Control=200; }//Speed 106 if(BluetoothData=='8'){ SPEED_Control=220; }//Speed 107 if(BluetoothData=='9'){ SPEED_Control=240; }//Speed 108 if(BluetoothData=='q'){ SPEED_Control=255; }//Speed 109 } 110} 111
Downloadable files
Schematic
Made using Fritzing
Schematic
Schematic
Made using Fritzing
Schematic
Comments
Only logged in users can leave comments