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

Arduino UNO and L298N Motor Driver Controlled Linear Actuators with Tactile Switches

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

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: Linear actuator motor
    • Pins: 12 V, Ground
  2. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver
    • 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 board
    • 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 unit
    • Pins: +, -
  5. Tactile Switch Buttons - 12mm Square

    • Description: Push button switch
    • Pins: 3, 1, 4, 2
  6. Resistor

    • Description: Resistor with 100 Ohms resistance
    • Pins: pin1, pin2

Wiring Details

Actuator Motor

Actuator Motor

L298N DC Motor Driver

Arduino UNO

12V Power Supply

Tactile Switch Buttons - 12mm Square

Resistor

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. It then continuously checks the state of the buttons to either extend or retract the actuators. The actuators are controlled by setting the appropriate pins on the L298N motor driver high or low.