Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Joystick-Controlled DC Motors and Linear Actuator System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Joystick-Controlled DC Motors and Linear Actuator System

Circuit Documentation

Summary

This circuit is designed to control two DC motors and a linear actuator using an Arduino UNO and a joystick module. The joystick's X and Y axes are read to control the speed and direction of the motors and the actuator. The circuit includes various components such as motor drivers, a rocker switch, and a voltage regulator to ensure proper operation.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. 250W 12V Electric Motor Brush Motor DC

    • Description: High-power DC motor.
    • Pins: POSITIF, NEGATIF
  3. Battery 12V

    • Description: Power source for the circuit.
    • Pins: -, +
  4. Linear Actuator

    • Description: Device that creates motion in a straight line.
    • Pins: +, -
  5. LM2596

    • Description: Voltage regulator.
    • Pins: IN, OUT
  6. Rocker Switch

    • Description: Switch to control the power supply.
    • Pins: 1, 2
  7. Motor Driver

    • Description: Driver for controlling motors.
    • Pins: VB+, VB-, M1A, M1B, M2A, M2B, 5V, GND
  8. BTS7960 Motor Driver

    • Description: High-power motor driver.
    • Pins: Pin 1, Pin 2, Pin 3, Pin 4, Pin 5, Pin 6, Pin 7, Pin 8, Pin 9, Pin 10, Pin 11, Pin 12
  9. Joystick Module

    • Description: Module to control motors and actuators using a joystick.
    • Pins: SW, VRY, VRX, VCC, GND

Wiring Details

Arduino UNO

250W 12V Electric Motor Brush Motor DC

Battery 12V

Linear Actuator

LM2596

Rocker Switch

Motor Driver

BTS7960 Motor Driver

Joystick Module

Code Documentation

/*
 * This Arduino Sketch controls two DC motors and a linear actuator using
 * a joystick module. The joystick's X and Y axes are read to control the
 * speed and direction of the motors and the actuator.
 */

#include <Arduino.h>

// Pin definitions
const int joystickVRX = A1;
const int joystickVRY = A0;
const int motor1PWM = 9;
const int motor1DIR = 8;
const int motor2PWM = 6;
const int motor2DIR = 5;
const int actuatorPWM = 12;
const int actuatorDIR = 11;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  // Initialize motor and actuator control pins
  pinMode(motor1PWM, OUTPUT);
  pinMode(motor1DIR, OUTPUT);
  pinMode(motor2PWM, OUTPUT);
  pinMode(motor2DIR, OUTPUT);
  pinMode(actuatorPWM, OUTPUT);
  pinMode(actuatorDIR, OUTPUT);
}

void loop() {
  // Read joystick values
  int xValue = analogRead(joystickVRX);
  int yValue = analogRead(joystickVRY);

  // Map joystick values to motor control signals
  int motor1Speed = map(xValue, 0, 1023, -255, 255);
  int motor2Speed = map(yValue, 0, 1023, -255, 255);

  // Control motor 1
  if (motor1Speed > 0) {
    digitalWrite(motor1DIR, HIGH);
    analogWrite(motor1PWM, motor1Speed);
  } else {
    digitalWrite(motor1DIR, LOW);
    analogWrite(motor1PWM, -motor1Speed);
  }

  // Control motor 2
  if (motor2Speed > 0) {
    digitalWrite(motor2DIR, HIGH);
    analogWrite(motor2PWM, motor2Speed);
  } else {
    digitalWrite(motor2DIR, LOW);
    analogWrite(motor2PWM, -motor2Speed);
  }

  // Control linear actuator
  int actuatorSpeed = map(yValue, 0, 1023, -255, 255);
  if (actuatorSpeed > 0) {
    digitalWrite(actuatorDIR, HIGH);
    analogWrite(actuatorPWM, actuatorSpeed);
  } else {
    digitalWrite(actuatorDIR, LOW);
    analogWrite(actuatorPWM, -actuatorSpeed);
  }

  // Small delay to stabilize readings
  delay(50);
}

This code initializes the necessary pins for controlling the motors and the linear actuator. It