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

Arduino UNO and L298N Motor Driver Controlled Linear Actuators with Button Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO and L298N Motor Driver Controlled Linear Actuators with Button Interface

Circuit Documentation

Summary

This circuit controls two linear actuators using an L298N motor driver and an Arduino UNO. The actuators extend 4 inches when a button is pressed and retract to zero when another button is pressed. The actuators move at a rate of 0.31 inches per second.

Component List

  1. Actuator Motor

    • Description: Motor used to actuate linear motion.
    • Pins: 12 V, Ground
  2. L298N DC Motor Driver

    • Description: Motor driver used to control the actuator motors.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  3. Arduino UNO

    • Description: Microcontroller used to control the motor driver and read button inputs.
    • 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
  4. 12V Power Supply

    • Description: Power supply providing 12V to the circuit.
    • Pins: +, -
  5. Tactile Switch Buttons - 12mm Square

    • Description: Buttons used to control the extension and retraction of the actuators.
    • Pins: 3, 1, 4, 2

Wiring Details

Actuator Motor 1

Actuator Motor 2

L298N DC Motor Driver

Arduino UNO

12V Power Supply

Tactile Switch Button 1

Tactile Switch Button 2

Code Documentation

/*
 * This Arduino sketch controls two linear actuators using an L298N motor driver.
 * The actuators extend 4 inches when a button is pressed and retract to zero
 * when another button is pressed. The actuators move at a rate of 0.31 inches
 * per second.
 */

const int in1 = 2; // L298N IN1 connected to Arduino D2
const int in2 = 3; // L298N IN2 connected to Arduino D3
const int in3 = 4; // L298N IN3 connected to Arduino D4
const int in4 = 5; // L298N IN4 connected to Arduino D5
const int buttonExtend = 8; // Button to extend actuators connected to D8
const int buttonRetract = 9; // Button to retract actuators connected to D9
const int actuatorTime = 12903; // Time to move 4 inches (4 / 0.31 * 1000)

void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(buttonExtend, INPUT);
  pinMode(buttonRetract, INPUT);
}

void loop() {
  if (digitalRead(buttonExtend) == HIGH) {
    extendActuators();
  }
  if (digitalRead(buttonRetract) == HIGH) {
    retractActuators();
  }
}

void extendActuators() {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  delay(actuatorTime);
  stopActuators();
}

void retractActuators() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(actuatorTime);
  stopActuators();
}

void stopActuators() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

This code initializes the pins connected to the L298N motor driver and the buttons. In the loop function, it checks if the extend or retract button is pressed and calls the appropriate function to move the actuators. The extendActuators and retractActuators functions control the direction of the actuators and stop them after the specified time.