Bluetooth controlled car arduino

Bluetooth Controlled Car

This is my first Arduino-based, Bluetooth-controlled RC car. It is controlled by a smart phone application.

Dual H-Bridge motor drivers L298

Maker Essentials — Micro-motors & Grippy Wheels

\t Arduino Bluetooth RC Car

Code for Arduino blootooth controlled RC Car

This is the code you will have to upload to your Arduino board.

1char t; 2 3void setup()  4pinMode(13,OUTPUT); //left motors forward 5pinMode(12,OUTPUT); //left motors reverse 6pinMode(11,OUTPUT); //right motors forward 7pinMode(10,OUTPUT); //right motors reverse 8pinMode(9,OUTPUT); //Led 9Serial.begin(9600); 10 11> 12 13void loop()  14if(Serial.available()) 15 t = Serial.read(); 16 Serial.println(t); 17> 18 19if(t == 'F') //move forward(all motors rotate in forward direction) 20 digitalWrite(13,HIGH); 21 digitalWrite(11,HIGH); 22> 23 24else if(t == 'B') //move reverse (all motors rotate in reverse direction) 25 digitalWrite(12,HIGH); 26 digitalWrite(10,HIGH); 27> 28 29else if(t == 'L') //turn right (left side motors rotate in forward direction, right side motors doesn't rotate) 30 digitalWrite(11,HIGH); 31> 32 33else if(t == 'R') //turn left (right side motors rotate in forward direction, left side motors doesn't rotate) 34 digitalWrite(13,HIGH); 35> 36 37else if(t == 'W') //turn led on or off) 38 digitalWrite(9,HIGH); 39> 40else if(t == 'w') 41 digitalWrite(9,LOW); 42> 43 44else if(t == 'S') //STOP (all motors stop) 45 digitalWrite(13,LOW); 46 digitalWrite(12,LOW); 47 digitalWrite(11,LOW); 48 digitalWrite(10,LOW); 49> 50delay(100); 51>

Источник

How to make Bluetooth Controlled Car using Arduino and L293D

In this tutorial, you will learn how to make a Bluetooth controlled car using Arduino and LM293 motor driver. Previously, I made tutorial one and tutorial two on how to design a robotic arm with Arduino. In this tutorial, I will show you how to design an Arduino RC car that is controlled via Bluetooth with your smartphone. This is a very interesting project as it will enable you explore the G-sensor and Bluetooth features in your smartphone. See video tutorial below.

Bluetooth controlled car

Figure one above shows the wooden board cut into a trapezoid with the caster wheel and the gear motors attached to the board.

Circuit diagram – Bluetooth controlled car

Bluetooth controlled car

Arduino robotic car design

To connect the Arduino robotic car to your phone, you need to download and install the RemoteXY application. Here is the link for Android and for iPhone. The application has the free version and the Pro version, I recommend you buy the Pro version, it gives a better response.

After that, you upload the Arduino code for the design to your Arduino board. Below is the Arduino code, however, make sure you added the RemoteXY library to your IDE before uploading the code. If you do not know how to add Arduino library, check this tutorial. Make sure the switch of the design is turned off before uploading the Arduino code. Upload the code below.

Arduino code

 ///////////////////////////////////////////// // RemoteXY include library // ///////////////////////////////////////////// /* RemoteXY select connection mode and include library */ #define REMOTEXY_MODE__SOFTWARESERIAL #include #include /* RemoteXY connection settings */ #define REMOTEXY_SERIAL_RX 2 #define REMOTEXY_SERIAL_TX 3 #define REMOTEXY_SERIAL_SPEED 9600 /* RemoteXY configurate */ unsigned char RemoteXY_CONF[] = < 3,0,23,0,1,5,5,15,41,11 ,43,43,1,2,0,6,5,27,11,5 ,79,78,0,79,70,70,0 >; /* this structure defines all the variables of your control interface */ struct < /* input variable */ signed char joystick_1_x; /* =-100..100 x-coordinate joystick position */ signed char joystick_1_y; /* =-100..100 y-coordinate joystick position */ unsigned char switch_1; /* =1 if switch ON and =0 if OFF */ /* other variable */ unsigned char connect_flag; /* =1 if wire connected, else =0 */ >RemoteXY; ///////////////////////////////////////////// // END RemoteXY include // ///////////////////////////////////////////// /* defined the right motor control pins */ #define PIN_MOTOR_RIGHT_UP 7 #define PIN_MOTOR_RIGHT_DN 6 #define PIN_MOTOR_RIGHT_SPEED 10 /* defined the left motor control pins */ #define PIN_MOTOR_LEFT_UP 5 #define PIN_MOTOR_LEFT_DN 4 #define PIN_MOTOR_LEFT_SPEED 9 /* defined the LED pin */ #define PIN_LED 13 /* defined two arrays with a list of pins for each motor */ unsigned char RightMotor[3] = ; unsigned char LeftMotor[3] = ; /* speed control of the motor motor - pointer to an array of pins v - motor speed can be set from -100 to 100 */ void Wheel (unsigned char * motor, int v) < if (v>100) v=100; if (v<-100) v=-100; if (v>0) < digitalWrite(motor[0], HIGH); digitalWrite(motor[1], LOW); analogWrite(motor[2], v*2.55); >else if (v <0) < digitalWrite(motor[0], LOW); digitalWrite(motor[1], HIGH); analogWrite(motor[2], (-v)*2.55); >else < digitalWrite(motor[0], LOW); digitalWrite(motor[1], LOW); analogWrite(motor[2], 0); >> void setup() < /* initialization pins */ pinMode (PIN_MOTOR_RIGHT_UP, OUTPUT); pinMode (PIN_MOTOR_RIGHT_DN, OUTPUT); pinMode (PIN_MOTOR_LEFT_UP, OUTPUT); pinMode (PIN_MOTOR_LEFT_DN, OUTPUT); pinMode (PIN_LED, OUTPUT); /* initialization module RemoteXY */ RemoteXY_Init (); >void loop() < /* event handler module RemoteXY */ RemoteXY_Handler (); /* manage LED pin */ digitalWrite (PIN_LED, (RemoteXY.switch_1==0)?LOW:HIGH); /* manage the right motor */ Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x); /* manage the left motor */ Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x); >

Once you’ve uploaded the sketch to the Arduino board, unplug the USB cable from the Arduino board and turn on the device. Turn on the Bluetooth device on your phone as well and open the RemoteXY application, click the + button on the top right corner of the application to add new device, then click Bluetooth for Android devices or Bluetooth BLE for Apple devices. Connect your phone’s Bluetooth to the Bluetooth on the RC robotic car, once that is done, the Bluetooth icon will appear on your phone to show that the Arduino application and the Android GUI to control the robotic car have been successfully uploaded, then click the Bluetooth icon and the phone will connect with the robot, immediately you will see the GUI to control the robotic car appear on phone screen. Now you can control your robotic car with your cell phone by holding down the directional button to the direction you want the car to go, or by tilting your phone to the direction you want the car to move after switching to G-sensor mode.

This is how you can design a cell phone controlled robotic car with Arduino and Bluetooth. I will be making more videos like this in the future, so, consider subscribing to my YouTube channel so you don’t miss any interesting tutorial.

Источник

Bluetooth Controlled Car

This is my first Arduino-based, Bluetooth-controlled RC car. It is controlled by a smart phone application.

Dual H-Bridge motor drivers L298

Maker Essentials — Micro-motors & Grippy Wheels

\t Arduino Bluetooth RC Car

Code for Arduino blootooth controlled RC Car

This is the code you will have to upload to your Arduino board.

1char t; 2 3void setup()  4pinMode(13,OUTPUT); //left motors forward 5pinMode(12,OUTPUT); //left motors reverse 6pinMode(11,OUTPUT); //right motors forward 7pinMode(10,OUTPUT); //right motors reverse 8pinMode(9,OUTPUT); //Led 9Serial.begin(9600); 10 11> 12 13void loop()  14if(Serial.available()) 15 t = Serial.read(); 16 Serial.println(t); 17> 18 19if(t == 'F') //move forward(all motors rotate in forward direction) 20 digitalWrite(13,HIGH); 21 digitalWrite(11,HIGH); 22> 23 24else if(t == 'B') //move reverse (all motors rotate in reverse direction) 25 digitalWrite(12,HIGH); 26 digitalWrite(10,HIGH); 27> 28 29else if(t == 'L') //turn right (left side motors rotate in forward direction, right side motors doesn't rotate) 30 digitalWrite(11,HIGH); 31> 32 33else if(t == 'R') //turn left (right side motors rotate in forward direction, left side motors doesn't rotate) 34 digitalWrite(13,HIGH); 35> 36 37else if(t == 'W') //turn led on or off) 38 digitalWrite(9,HIGH); 39> 40else if(t == 'w') 41 digitalWrite(9,LOW); 42> 43 44else if(t == 'S') //STOP (all motors stop) 45 digitalWrite(13,LOW); 46 digitalWrite(12,LOW); 47 digitalWrite(11,LOW); 48 digitalWrite(10,LOW); 49> 50delay(100); 51>

Источник

Bluetooth Controlled RC car – Arduino Program:

Today in this article we are going to discuss How to make a Bluetooth Controlled car using Arduino so without wasting any time let’s make the Arduino car . Arduino Bluetooth control car is a simple robot car that can be controlled by your smartphone. This Smartphone gives a Bluetooth signal to the car and from the signal, the car works.

Components used in the Arduino Car project:

  1. HC-05 Bluetooth: https://www.utsource.net/itm/p/7566177.html
  2. Arduino Uno R3 Board: https://www.utsource.net/itm/p/7281975.html
  3. L298N Motor Driver: https://www.utsource.net/itm/p/11527364.html
  4. DC Motor: https://www.utsource.net/itm/p/11527481.html
  5. 18650 Battery and Holder: https://www.utsource.net/itm/p/7961336.html

Tools Needed:

How can I make my robot car Bluetooth?

Arduino Bluetooth control car is a simple robot car that can be controlled by your smartphone. This Smartphone gives a Bluetooth signal to the car and from the signal, the car works.

For running the car wirelessly we are using the HC-05 Bluetooth module. We connect your phone with the BlueTooth module. Then the phone sends some random characters which are stated for running the car.

In general, case, F is used for forwarding car movement. B is used for a backward car moment. Similarly, Other characters are used for other directions which are mentioned in the Arduino code.

Make Bluetooth Controlled car using Arduino:

For controlling the Motors we are using an l298n motor driver. you can also use l293d also. I chose l298n in over l293d because it has high power output. If you are interested in l293d Bluetooth car then make sure you subscribe to our YouTube channel.

Now for running the car obviously we need a power source. So, For the power source, we are using 18650 Lithium-ion cells.

You can also use any other battery which is listed below

Video Tutorial:

Watch the YouTube video from Make DIY And I hope you will understand everything.

Motor:

For the motor section, I am using a TT motor. These are some great for our Bluetooth control car project. And it has some low voltage range like 3V to 6V. So, These Motors are great for DIY projects. Here I have also added some high torque Motors well if you want more power.

Here, I have used for motors two Motors each site. Two side Motors are connected in parallel for high torque. And the two-sided Motors cables will go to the motor driver.

Motor Driver:

For the motor driver, I am using an l298n H Bridge motor driver. This is some good power output so I am using it. Now just connect two-sided motor cables with the motor driver.

The main controller Arduino Uno R3:

For the controller, I am using a basic Arduino microcontroller i.e. Arduino Uno R3. Now used double-sided tape for attaching it on the wood. And now I have connected the data warehouse with the l298n motor driver for sending the reader purses which will drive the motor.

Bluetooth module:

For the Bluetooth module, I am using HC 05 Bluetooth module. You can also use an HC-06 Bluetooth module as well. For keeping it simple I am using it.

Note: You must know that when you are uploading the code to the Arduino. You must unplug the RX and TX pin of the Bluetooth module. Otherwise, you will not be able to upload the code to the Arduino.

Arduino Bluetooth car circuit diagram:

smartphone controlled Arduino Bluetooth car code.

Software/ Coding part:

For uploading the code choose the right board. Then choose the write com port and then compile first and then upload to Arduino. As simple as that.

Now install the app in your Android device and then open it and connect it with the Bluetooth HC 05. Now you can see the red blinking but will be changed in green. So, It means that you are connected with the Bluetooth car robot.

Next, you can perform the forward-backward Left Right functions and you can see the queries working.

/* Code Name: Arduino Bluetooth Control Car Code URI: https://circuitbest.com/category/arduino-projects/ Author: Make DIY Author URI: https://circuitbest.com/author/admin/ Description: This program is used to control a robot using a app that communicates with Arduino through a bluetooth module. App URI: https://bit.ly/2BlMAea Version: 1.0 License: Remixing or Changing this Thing is allowed. Commercial use is not allowed. */ #define in1 5 //L298n Motor Driver pins. #define in2 6 #define in3 10 #define in4 11 #define LED 13 int command; //Int to store app command state. int Speed = 204; // 0 — 255. int Speedsec; int buttonState = 0; int lastButtonState = 0; int Turnradius = 0; //Set the radius of a turn, 0 — 255 Note:the robot will malfunction if this is higher than int Speed. int brakeTime = 45; int brkonoff = 1; //1 for the electronic braking system, 0 for normal. void setup() < pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); pinMode(LED, OUTPUT); //Set the LED pin. Serial.begin(9600); //Set the baud rate to your Bluetooth module. >void loop() < if (Serial.available() >0) < command = Serial.read(); Stop(); //Initialize with motors stoped. switch (command) < case 'F': forward(); break; case 'B': back(); break; case 'L': left(); break; case 'R': right(); break; case 'G': forwardleft(); break; case 'I': forwardright(); break; case 'H': backleft(); break; case 'J': backright(); break; case '0': Speed = 100; break; case '1': Speed = 140; break; case '2': Speed = 153; break; case '3': Speed = 165; break; case '4': Speed = 178; break; case '5': Speed = 191; break; case '6': Speed = 204; break; case '7': Speed = 216; break; case '8': Speed = 229; break; case '9': Speed = 242; break; case 'q': Speed = 255; break; >Speedsec = Turnradius; if (brkonoff == 1) < brakeOn(); >else < brakeOff(); >> > void forward() < analogWrite(in1, Speed); analogWrite(in3, Speed); >void back() < analogWrite(in2, Speed); analogWrite(in4, Speed); >void left() < analogWrite(in3, Speed); analogWrite(in2, Speed); >void right() < analogWrite(in4, Speed); analogWrite(in1, Speed); >void forwardleft() < analogWrite(in1, Speedsec); analogWrite(in3, Speed); >void forwardright() < analogWrite(in1, Speed); analogWrite(in3, Speedsec); >void backright() < analogWrite(in2, Speed); analogWrite(in4, Speedsec); >void backleft() < analogWrite(in2, Speedsec); analogWrite(in4, Speed); >void Stop() < analogWrite(in1, 0); analogWrite(in2, 0); analogWrite(in3, 0); analogWrite(in4, 0); >void brakeOn() < //Here's the future use: an electronic braking system! // read the pushbutton input pin: buttonState = command; // compare the buttonState to its previous state if (buttonState != lastButtonState) < // if the state has changed, increment the counter if (buttonState == 'S') < if (lastButtonState != buttonState) < digitalWrite(in1, HIGH); digitalWrite(in2, HIGH); digitalWrite(in3, HIGH); digitalWrite(in4, HIGH); delay(brakeTime); Stop(); >> // save the current state as the last state, //for next time through the loop lastButtonState = buttonState; > > void brakeOff()

Simple troubleshoot if the car is not going in the right direction:

If this happens and your car is not going in the right direction then you don’t have to modify any code. You have to just change the motor driver wires. Now your car will go in the right direction.

You can also read another article about Arduino projects.

Источник

Читайте также:  Подключение bluetooth клавиатуры apple
Оцените статью
Adblock
detector