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

Arduino UNO Controlled DC Motor with Push Button Activation

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled DC Motor with Push Button Activation

Circuit Documentation

Summary

This circuit is designed to control a DC motor using an Arduino UNO and an L298N motor driver. The motor is powered by a DC power source, and its operation is controlled via a push switch. The Arduino UNO is programmed to manage the motor's direction and speed based on the input from the push switch.

Component List

  1. DC Power Source

    • Description: Provides the necessary voltage and current to power the motor and other components.
    • Pins: Ground, Positive
  2. DC Motor

    • Description: Converts electrical energy into mechanical motion.
    • Pins: pin 1, pin 2
  3. Arduino UNO

    • Description: A microcontroller board used for controlling the motor and reading the push switch input.
    • 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. L298N DC Motor Driver

    • Description: A dual H-bridge motor driver that allows control of the motor's direction and speed.
    • 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
  5. Resistor

    • Description: Limits the current flow in the circuit.
    • Pins: pin1, pin2
    • Properties: Resistance: 10000 Ohms
  6. 2Pin Push Switch

    • Description: A switch used to control the motor operation.
    • Pins: Input +, Output +

Wiring Details

DC Power Source

DC Motor

Arduino UNO

L298N DC Motor Driver

Resistor

2Pin Push Switch

Code Documentation

Arduino UNO Code

int motor1pin1 = 2;
int motor1pin2 = 3;
int buttonpin = 4;

void setup() {
  Serial.begin(9600);
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(buttonpin, INPUT);
}

#define TIME4_1_METER  550  //CHANGE FOR CALIBRATION
#define DISTANCE_CM   600

void loop() {
  while (digitalRead(buttonpin) == false) {
    delay(20);
  }
  digitalWrite(motor1pin1, HIGH);
  digitalWrite(motor1pin2, LOW);

  int travel_time = (7 * DISTANCE_CM) + 200;
  Serial.println(travel_time);
  delay(travel_time);

  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, LOW);
}

This code initializes the pins for the motor and the push switch. In the setup function, the serial communication is started, and the pin modes are set. The loop function waits for the push switch to be pressed, then runs the motor for a calculated travel time, and finally stops the motor.