Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

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

Image 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

  • Pin 12 V connected to L298N DC Motor Driver OUT1
  • Pin Ground connected to L298N DC Motor Driver OUT2

Actuator Motor

  • Pin 12 V connected to L298N DC Motor Driver OUT3
  • Pin Ground connected to L298N DC Motor Driver OUT4

L298N DC Motor Driver

  • Pin GND connected to Arduino UNO GND and 12V Power Supply -
  • Pin 5V connected to Arduino UNO 5V through Resistor pin2
  • Pin 12V connected to 12V Power Supply +
  • Pin OUT1 connected to Actuator Motor 12 V
  • Pin OUT2 connected to Actuator Motor Ground
  • Pin OUT3 connected to Actuator Motor 12 V
  • Pin OUT4 connected to Actuator Motor Ground
  • Pin ENA connected to L298N DC Motor Driver +5V-J1
  • Pin ENB connected to L298N DC Motor Driver +5V-J2
  • Pin IN1 connected to Arduino UNO D2
  • Pin IN2 connected to Arduino UNO D3
  • Pin IN3 connected to Arduino UNO D4
  • Pin IN4 connected to Arduino UNO D5

Arduino UNO

  • Pin GND connected to 12V Power Supply - and L298N DC Motor Driver GND
  • Pin 5V connected to L298N DC Motor Driver 5V through Resistor pin2
  • Pin D2 connected to L298N DC Motor Driver IN1
  • Pin D3 connected to L298N DC Motor Driver IN2
  • Pin D4 connected to L298N DC Motor Driver IN3
  • Pin D5 connected to L298N DC Motor Driver IN4
  • Pin D8 connected to Tactile Switch Buttons - 12mm Square pin 4
  • Pin D9 connected to Tactile Switch Buttons - 12mm Square pin 4

12V Power Supply

  • Pin + connected to L298N DC Motor Driver 12V
  • Pin - connected to Arduino UNO GND and L298N DC Motor Driver GND

Tactile Switch Buttons - 12mm Square

  • Pin 4 connected to Arduino UNO D8
  • Pin 4 connected to Arduino UNO D9

Resistor

  • Pin pin2 connected to Arduino UNO 5V
  • Pin pin2 connected to L298N DC Motor Driver 5V

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.