Skip to content

4.2.9. Joystick Steering DC Rover Drive

| Description In Project 99, learners will construct an expert interactive system titled 'Joystick Steering DC Rover Drive'. This manual details the complete synthesis of XY Joystick + 2 DC Motors + L298N Driver + Traffic Light Module into an intuitive, high-performance automated control platform.|------------------|----------------------------------------------------------------| | Use case |This project connects to real-world industrial and IoT applications such as: Project 99 equips students with professional skills in embedded human-machine interface (HMI) design and automated motion control.|

Components (Things You will need)

Arduino Uno Arduino USB Cable Bread Board Jumper Wires Motor Driver Joystick

Building the circuit

Things Needed:

  • Arduino Uno Core Board
  • XY Joystick
  • 2 DC Motors
  • L298N Driver
  • USB Cable & Jumper Wires
  • Bread Board

Mounting the component on the breadboard and wiring the circuit

Step 1: Connect the Arduino 5V pin to the breadboard's positive (+) power rail and the Arduino GND pin to the negative (-) power rail.

Step 2: Place the XY Joystick on the breadboard. - Connect the VCC pin to the 5V power rail on the breadboard - Connect the GND pin to the ground rail on the breadboard - Connect the VRx pin to Analog Pin A0 - Connect the VRy pin to Analog Pin A1

Step 3: Place the L298N Motor Driver on the breadboard (for the Dual DC Motors). - Connect the 5V pin to the 5V power rail on the breadboard - Connect the GND pin to the ground rail on the breadboard - Connect ENA, IN1, and IN2 to Digital Pins 9, 8, and 7 respectively (for Motor A) - Connect ENB, IN3, and IN4 to Digital Pins 3, 6, and 5 respectively (for Motor B) - Connect the DC motors to the driver's output terminals

Step 4: Ensure all components share a common GND connection, then verify all wiring before connecting the Arduino Uno to your computer using the USB cable.

Components on breadboard

Step 5: After confirming that all connections are correct, connect the USB cable to the Arduino Uno board and the computer to power the circuit.

Make sure to connect the Arduino USB cable to the Arduino board.

PROGRAMMING

Step 1: Open your Arduino IDE. See how to set up here: Getting Started.

Step 2: Write the complete program implementing the system logic with appropriate pin definitions, setup configuration, and the main control loop.

// Project 99: Joystick Steering DC Rover Drive
const int VRX_PIN = A0; 
const int VRY_PIN = A1;
const int ENA = 9; 
const int IN1 = 8; 
const int IN2 = 7;
const int ENB = 3; 
const int IN3 = 6; 
const int IN4 = 5;

void setup() {
  pinMode(ENA, OUTPUT); 
  pinMode(IN1, OUTPUT); 
  pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); 
  pinMode(IN3, OUTPUT); 
  pinMode(IN4, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int xVal = analogRead(VRX_PIN); 
  int yVal = analogRead(VRY_PIN);

  // Calculate speed and steering
  int speed = map(abs(yVal - 512), 0, 512, 0, 255);
  int steering = map(xVal, 0, 1023, -127, 127);

  // Differential drive logic
  int leftMotor = speed + steering;
  int rightMotor = speed - steering;

  // Constrain to PWM range
  leftMotor = constrain(leftMotor, -255, 255);
  rightMotor = constrain(leftMotor, -255, 255);

  // Apply motor logic
  digitalWrite(IN1, leftMotor > 0);
  digitalWrite(IN2, leftMotor < 0);
  digitalWrite(IN3, rightMotor > 0);
  digitalWrite(IN4, rightMotor < 0);

  analogWrite(ENA, abs(leftMotor));
  analogWrite(ENB, abs(rightMotor));

  delay(20);
}


Step 7: Save your code. See the Getting Started section

Step 8: Select the arduino board and port See the Getting Started section:Selecting Arduino Board Type and Uploading your code.

Step 9: Upload your code. See the Getting Started section:Selecting Arduino Board Type and Uploading your code

CONCLUSION

Operating physical input devices instantly modifies actuator behavior and updates visual indicators in real time.