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

Arduino UNO Controlled DC Motor with Potentiometer Speed Adjustment

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled DC Motor with Potentiometer Speed Adjustment

Circuit Documentation

Summary

This circuit is designed to control a DC motor using an Arduino UNO, a potentiometer, and an L298N DC motor driver. The potentiometer is used to adjust the speed of the motor, which is read by the Arduino and then used to control the motor driver. The motor driver, in turn, powers the DC motor based on the signals received from the Arduino.

Component List

  1. Arduino UNO

    • Description: A 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. L298N DC motor driver

    • Description: A dual H-Bridge motor driver module that allows control of the speed and direction of two DC 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. Motor amarillo motorreductor hobby

    • Description: A small DC motor with a gearbox for hobby projects.
    • Pins: vcc, GND
  4. Potentiometer

    • Description: A variable resistor used to adjust voltage levels.
    • Pins: GND, Output, VCC
  5. 9V battery

    • Description: A standard 9V battery used to power the motor driver.
    • Pins: +, -

Wiring Details

Arduino UNO

L298N DC motor driver

Motor amarillo motorreductor hobby

Potentiometer

9V battery

Documented Code

Arduino UNO Code

// Declaring where our module is wired
int in1 = 8;
int in2 = 9;
int ConA = 10; // Don't forget this is a PWM DI/DO
int speed1;

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop() {
  digitalWrite(in1, LOW);  // Switch between this HIGH and LOW to change direction
  digitalWrite(in2, HIGH);
  speed1 = analogRead(A0);  // We read the analog value from the potentiometer
  speed1 = speed1 * 0.2492668622;  // Calibrate it
  analogWrite(ConA, speed1);  // Then inject it to our motor
}

This code initializes the pins connected to the motor driver as outputs and reads the analog value from the potentiometer to control the speed of the motor. The direction of the motor can be changed by toggling the digitalWrite values for in1 and in2.