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

Arduino UNO Controlled DC Motor with Variable Speed

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

Circuit Documentation

Summary

This circuit is designed to control a DC motor using an Arduino UNO microcontroller and an L298N DC motor driver. The motor's speed is regulated by a potentiometer, which provides analog input to the Arduino. The Arduino processes this input and sends PWM signals to the L298N driver to control the motor speed. The motor driver is powered by a 12V battery, which also supplies the motor.

Component List

Arduino UNO

L298N DC Motor Driver

12V Battery

DC Motor

Potentiometer

Wiring Details

Arduino UNO

L298N DC Motor Driver

DC Motor

Potentiometer

Documented Code

#define In1 9
#define In2 8
#define speedpin 10
#define an A0
float speed;

void setup() {
  pinMode(In1, OUTPUT);
  pinMode(In2, OUTPUT);
  pinMode(speedpin, OUTPUT);
}

void loop() {
  digitalWrite(In1, LOW);
  digitalWrite(In2, HIGH);
  speed = analogRead(an);
  speed = speed * (255.0 / 1023.0);
  analogWrite(speedpin, speed);
}

Code Explanation