Brushed DC Motor Controller

Brushed DC Motor controller using Arduino UNO, Project controls the speed of motor using potentiometer and Direction using push switch, project built using Arduino UNO and LMD18201 IC, PWM duty cycle span 0 to 100%, frequency 900Hz. Supply up to 50V DC and Maximum load up to 3Amps with large size heating  and fan on heatsing on motor driver IC.


Arduino Pins Configuration

  • LMD18201 Direction Pin >> D7 Arduino
  • LMD18201 PWM Pin>> D5 Arduino
  • Potentiometer 10K >> A0 ( Arduino Analog Pin A0)
  • Tactile Switch for Direction Control >>A1 ( Arduino Pin A1 Pull Down Resistor of 10K)


Arduino Code


/* Brushed DC Motor Controller
* PCB Layout , Schematic , Arduino Code Available https://www.twovolt.com
* Modified Code, Original Code by Dejan Nedelkovski (HowToMechatronics)
*/
#define PWM 5
#define DIR 7
#define SWITCH A1
int rotDirection = 0;
int pressed = false;
void setup() {
pinMode(PWM, OUTPUT);
pinMode(DIR, OUTPUT);
pinMode(SWITCH, INPUT);
// Set initial CCW/CW direction
digitalWrite(DIR, LOW);
}
void loop() {
int potValue = analogRead(A0); // Read potentiometer value
int pwmOutput = map(potValue, 0, 1023, 0 , 255); // Map the potentiometer value from 0 to 255
analogWrite(PWM, pwmOutput); // Send PWM signal to LMD18200 PWM PIN
// Read SWITCH – Debounce
if (digitalRead(SWITCH) == true) {
pressed = !pressed;
}
while (digitalRead(SWITCH) == true);
delay(200);
// If SWITCH is pressed – change rotation direction
if (pressed == true & rotDirection == 0) {
digitalWrite(DIR, HIGH);
rotDirection = 1;
delay(1000);
}
// If SWITCH is pressed – change rotation direction
if (pressed == false & rotDirection == 1) {
digitalWrite(DIR, LOW);
rotDirection = 0;
delay(1000);
}
}


Leave a Reply

Your email address will not be published. Required fields are marked *