Hello readers, hope you are doing fine. In this article, we are going to teach you a very interesting project that is how to make a DC motor speed controlcircuit using Arduino UNO. Full working of the project and detailed explanation is on our website. You can not regulate the speed of a DC motor directly but using this circuit it is possible to do so. We are using an L298N motor driver module here but you can use other drivers as well. The image of the complete project is also given below.
You can rotate the potentiometer and the speed of the motor varies accordingly. The Arduino generates control signals based on the input from the variable resistor but the motor can not process them directly so we are using an L298N motor driver. This driver module provides the correct output signals so the motor can rotate perfectly. You can check the output values generated by the variable resistor on the serialmonitorscreen.
- Arduino UNO
- DC motor
- Jumper wires and a breadboard
- 9 volts battery
- 10K potentiometer
- L298n motor driver
- USB cable for uploading the code
Connect 5 volts pin of the Arduino with the 5 volts pin of the L298n motor driver module and one side pin of the 10K ohm potentiometer. Attach the GND pin of the Arduino with the GND pin of the L298n module and another side pin of the 10K potentiometer. Join the middle pin of the potentiometer with the analog-0 pin of the Arduino. Take a 9 volts battery and connect its positive wire with the 12 volts pin of the L298n module and its negative wire with the GND pin of the Arduino. Join the IN1 pin of the motor driver module with the digital-4 pin of the Arduino and the IN2 pin of the driver module with the digital-3 pin of the Arduino. At last, take a DC motor and connect its wires with the output pins of the driver module.
DC Motor Speed Control Arduino CodeNOTE: Please upload the code which is given below to the Arduino.
// TECHATRONIC.COM
void setup()
{
Serial.begin(9600);
pinMode(3,OUTPUT); // Motor pin 1
pinMode(4,OUTPUT); // Motor pin 2
digitalWrite(4,LOW); // Normally LOW inthis pin
pinMode(A0,INPUT); // 10k Potentiometer
}
void loop()
{
int s=analogRead(A0); // 10k Potentiometer
int z=map(s,0,1024,0,255);
Serial.println(z);
analogWrite(3,z);
}
We hope that you like this project on DC motor speed control. Do check out the latest tutorials on Arduino and Raspberry Pi uploaded by us.
HAPPY LEARNING!
Comments