How To Make a Joystick Control Car

0

 in this article, we are going to Make Joystick Control Car with Arduino UNO , L293D Motor Driver, and Joystick Module. Here you will get Fully Detailed instructions for making Arduino Joystick Controlled Car. Codes are also Included.

I have tried to provide you all the must-have Circuit Schematics and Diagrams in this article. My intention was to give you all in one guide for making joystick Car.

Joystick controlled car is a motion controlled car. Here, the Joystick can be used in two ways by using the button underneath the Joystick: By changing the Gear and moving the Joystick left ,right, forward and backward the car can be controlled accordingly.

If you want to make a School/ College project then this project is for you. You would not need any special knowledge for making the Arduino joystick control car. So, you should definitely try it.

WATCH YOUTUBE VIDEO

Watch the Full Video and you will understand everything. Next, follow the step by step guide below.

Arduino joystick Control Car Video

JOYSTICK CONTROL CAR WORKING

This is a simple Micro-controller based car. The Micro-Controller is connected to the car. The Arduino is doing all this job. For receiving data wire we are using the Joystick module. At first, We have to connect the Joystick module with the wires you want to control. Now, we are doing different operations such as when we move the forward button then the Joystick sends the value to the microcontroller. Next, we have to code in a way that if Arduino Gets a Certainvalue we have to make a certain condition for running the car in a certain direction. So, basically, there are many move cases in the Arduino code. For a known condition or a moving case, the car will perform the added functions in the code.

COMPONENTS REQUIRED

Item Image

Item Name

Quantity

Shop Online

Plywood 16cm X10cm

1 No

Caster Wheels

1 No

Arduino UNO

1 No

L298N Motor Driver

1 NO

dc gear motor

2 no

Wheel

2 no

Joystick

1 No

Buzzer

1 No

18650 cells

1 No

Switch

1 No

18650 battery holder

2 No Order Now

Jumper wires

Enough

TOOLS REQUIRED

Tool Image

Tool Name

Shop Online

Gun gum

Soldering rod with lead

Screwdriver

APPS AND ONLINE SERVICES

Arduino IDE

CIRCUIT DIAGRAM

Arduino Bluetooth Control car with L293D Motor Driver

STEPS TO MAKING

I have divided the joystick control car into several steps. By this, you can understand the Arduino car more easily. Please don’t skip any step otherwise it will be difficult to replicate.

Step 1:

First, you will need 2 gear Motors. Sometimes the motor doesn’t come with wire attached. So, In that case, you have to attach the wire to the motors with a soldering iron.

Step 2:

In the same way, I have connected wires with Motors. One suggestion to solder is that please don’t heat the motor terminals too much they will be damaged if you heat that too much. After that, I tested all the motors before connecting and it works just fine.

Step 3:

fix the 360-degree wheel to plywood with help of screws

Step 4:

Now take a Piece of Plywood dimension of 16CM x 10CM. Now use a Glue Gun and place the motor on the Plywood corners. Use the same technique and connect all 2 Motors on the chassis.

Step 5:

I have attached 2 Motor in the Plywood. One suggestion to you is to align the motors. Otherwise, the motors will not go straight.

Step 6:

First take Arduino Uno and them attach it on the Chassis. Many people use Hot Glue to attach but I don’t recommend that at all. The coper traces under the PCB may be damaged for the hot glue. So, I used Double sided tape for attaching the Board.For controlling the Motors we will definitely need a motor driver. The L298n and the L293D motor drivers are most commonly used with Arduino. All these drivers have an inbuilt H-Bridge inside in it for controlling the motors.

Step 7:

Here is the Left and the Right side view of the Car. You can see the connection more clearly here. If you change the motor wires then the motor rotation will also change. Just connect all the motor as shown in the picture and will work just fine.

Note:

Suppose you are powering a DC motor with a power source like 9V Battery. Just think that your motor is rotating in a certain direction. Now, If you change the connection (Suppose previously you connected Red Wire to the +ve and the Gray wire with the -ve of the battery. So, here changing connection means you have to connect the Red wire with the -ve and Gray wire with the +ve) then the motor will rotate in the opposite direction. This is the property of DC Motor. In this way, you can also check your DC Motor is working or not.

Step 8:

I have used 18650 Batteries for Joystick Control Car. You can also use Li-Po Batteries or Lead Acid Batteries as well. My recommendation is to go with Li-ion or Li-Po Battery because this is most commonly used in Projects. Nowadays you can get 18650 Batteries as cheap as 2$. And these batteries will give you the most power.

Connect the Battery wires with the EXT_PWR Terminal Block. The Battery Terminal block has a Switch inbuilt in it. It is used to turn On/ Off the car. I have attached Double-sided tape with the battery holder and connected with the Chassis.

Note:

But one thing I should definitely mention that Li Batteries are great for DIY Projects. But use with care. Charge with Dedicated chargers. Just being at the safe side you may use the TP4056 Li Charger module. And never ever Over-charge, Over-discharge, or short circuit these batteries. It may blast.

Step 9:

Remove the jumper caps

Step 10:

Connect the wires as per the shown in the figure or table

wire connection between Arduino and motor driver

Motor Driver(L298n) Arduino UNO
IN 1 Pin 4
IN 2 Pin 5
IN 3 Pin 6
IN 4 Pin 7
EN A Pin 9
EN B Pin 10

Step 11:

Connect the wires as per the shown in the figure or table

wire connection between Arduino and Joystick Module

>
Joystick Module Arduino UNO
+5ve 5v
GND GND
VRx pin A0
VRy pin A1
sw Pin 8

Step 12:

Next, connect your Arduino with your PC or MAC. After that, we will dive into the software section.

Now, I have provided the code below. Just copy the code and paste it in your Arduino IDE. Before uploading the code to Arduino we need to add a library to Arduino. Just go to the following.

CODE

/*  Arduino DC Motor Control - PWM | H-Bridge | L298N
         Example 01 - joystick control car with buzzer
 using Arduino and L298N motor driver
   Made by udaykiran, Electro mechanics
*/

#define enA 9
#define in1 4
#define in2 5
#define enB 10
#define in3 6
#define in4 7
#define sw 8
int horn = 13;
int motorSpeedA = 0;
int motorSpeedB = 0; 

void setup() {
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(horn,OUTPUT);
  pinMode(sw,INPUT_PULLUP);// setting pin sw as input
 
}

void loop() {                   
  int xAxis = analogRead(A0); // Read Joysticks X-axis
  int yAxis = analogRead(A1); // Read Joysticks Y-axis
  int buttonState = digitalRead(sw);
  if(buttonState ==LOW){ 
    digitalWrite(horn,HIGH);// Turn LED ON
  }
  else{
    digitalWrite(horn,LOW);// Turn LED OFF
  }
 
  // Y-axis used for forward and backward control
  if (yAxis < 470) {
    // Set Motor A backward
                  
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
                  
    // Set Motor B backward
                  
    digitalWrite(in3, HIGH);
    digitalWrite(in4, LOW);
                  
    // Convert the declining Y-axis readings for going backward from 470 to 0 into 0 to 255 value for the PWM signal for increasing the motor speed
    motorSpeedA = map(yAxis, 470, 0, 0, 255);
    motorSpeedB = map(yAxis, 470, 0, 0, 255);
  }
  else if (yAxis > 550) {
    // Set Motor A forward
    digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);
    // Set Motor B forward
    digitalWrite(in3, LOW);
    digitalWrite(in4, HIGH);
    // Convert the increasing Y-axis readings for going forward from 550 to 1023 into 0 to 255 value for the PWM signal for increasing the motor speed
    motorSpeedA = map(yAxis, 550, 1023, 0, 255);
    motorSpeedB = map(yAxis, 550, 1023, 0, 255);
  }
  // If joystick stays in middle the motors are not moving
  else {
    motorSpeedA = 0;
    motorSpeedB = 0;
  }

  // X-axis used for left and right control
  if (xAxis < 470) {
    // Convert the declining X-axis readings from 470 to 0 into increasing 0 to 255 value
    int xMapped = map(xAxis, 470, 0, 0, 255);
    // Move to left - decrease left motor speed, increase right motor speed
    motorSpeedA = motorSpeedA - xMapped;
    motorSpeedB = motorSpeedB + xMapped;
    // Confine the range from 0 to 255
    if (motorSpeedA < 0) {
      motorSpeedA = 0;
    }
    if (motorSpeedB > 255) {
      motorSpeedB = 255;
    }
  }
  if (xAxis > 550) {
    // Convert the increasing X-axis readings from 550 to 1023 into 0 to 255 value
    int xMapped = map(xAxis, 550, 1023, 0, 255);
    // Move right - decrease right motor speed, increase left motor speed
    motorSpeedA = motorSpeedA + xMapped;
    motorSpeedB = motorSpeedB - xMapped;
    // Confine the range from 0 to 255
    if (motorSpeedA > 255) {
      motorSpeedA = 255;
    }
    if (motorSpeedB < 0) {
      motorSpeedB = 0;
    }
  }
  // Prevent buzzing at low speeds (Adjust according to your motors. My motors could not start moving if PWM value was below value of 70)
  if (motorSpeedA < 70) {
    motorSpeedA = 0;
  }
  if (motorSpeedB < 70) {
    motorSpeedB = 0;
  }
  analogWrite(enA, motorSpeedA); // Send PWM signal to motor A
  analogWrite(enB, motorSpeedB); // Send PWM signal to motor B
}

Now choose the Board as Arduino Uno and Choose the right COM port. Next compile the code first and then Upload the code to Arduino.

Step 13:

Now I attached the 18650 Batteries in the 18650 Battery Holder. Before powering the car just check all the necessary connections like Battery Power +ve and -ve is connected or not, joystick modules Polarity is right or different. A simple mistake can lead you to damage any modules. And turned on the Switch. Here you will see the L293D Motor Driver’s Green LED glow after turning it on.

Step 14:

Now you will need the joystick for controlling the car.

Output Video

I hope this step by step guide will help you for making the Arduino Joystick control car with L293D whether you are a Beginner or it is your first-ever Arduino project. All components link are included with proper pricing. Hope this helps. If you have any queries or any suggestions then don’t forget to mention that into the comment section. I will definitely try to help you. Moreover, you can subscribe to our Youtube channel Electromechanics for more amazing content like this.

Thank you

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !