Back to Arduino Step By Step Course

Lesson 108: Control DC motor using FR120N AOD4184 D4184 LR7843 HW-532 MOSFET module (3 projects)


If you don't like to see ads while video is being played you can purchase this course for $200 from Udemy or purchase YouTube premium Here

Lesson 108: Control DC motor using FR120N AOD4184 D4184 LR7843 HW-532 MOSFET module (3 projects)

Please select other codes for this lecture from the links below.

Please download required files for this code

Part 5: DC Motors

This is for controlling speed of the motor using Variable Resitor (Potentiometer) and we use a push button to start or stop the motor using Arduino boards. We use the module with FR120N , LR7843 and D4184 MOSFET to turn ON/OFF DC load up to up to 10A. HW-532 optically isolated from 5V to 30V load up to 10A depending on the module. Schematic shown, wiring diagram explained, different method of wiring with push button and potentiometer also shown.

<>Using this moduel we can't control direction of rotation of the motor.

Projects

In Project 3 in lesson 108 We Control speed of the motor using Arduino code.

Timing of chapters in the video

00:00 Introduction
03:32 Schematic Explained
05:16 Components under magnifier
06:48 Datasheet for Mosfet viewed
08:00 Efficiency: which one to use
11:14 Project 1: Basic ON/OFF with or without Arduino
13:56 Project 1: Wiring
15:05 Project 1: Code
15:36 Project 2: Speed Control using Arduino
19:31 Project 3: Motor Speed with Potentiometer and stop push button
19:43 Project 3: Wiring
22:08 Project 3: Code

  /* 
 * Lesson 108-3: Controlling Speed of motor using Variable Resistor (potentiometer) and using Start/Stop push button with Arduino.
 * 
 * In this lesson we learn how to use  the module with FR120N , LR7843 and D4184 MOSFET to turn ON/OFF DC load up to up to 10A. HW-532 optically isolated from 5V to 30V load up to 10A depending on the module. Schematic shown, wiring diagram explained, different 
 method of wiring with push button and potentiometer also shown. 
 Video https://youtu.be/eqXaqRFAWrA
  
 Written by Ahmad Shamshiri for RoboJax.com
 // Published on Aug 25, 2022 in Aajx, ON, Canada.
 
  
   Project 1: Turning ON/OFF a motor or load 
   Project 2: Controllign Speed using Arduino code 
   Project 3: Controllign Speed using potentiometer and a push button (this project)
 
   * Watch Video instrution for this code:https://youtu.be/eqXaqRFAWrA
   * 
   * This code is part of Arduino Step by Step Course which starts here:  https://youtu.be/-6qSrDUA5a8
   * 
   * for library of this code visit http://robojax.com/
   * 
  If you found this tutorial helpful, please support me so I can continue creating 
  content like this. Make a donation using PayPal by credit card https://bit.ly/donate-robojax 
  
 
  
   *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
   * This code has been download from Robojax.com
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
  */
 
const int POT_PIN =A0;//can change
const int MOTOR_OUT_PIN = 3;//~
const int START_STOP_PIN=2;//for push button switch

const int SPEED_MAX = 100;// in %
const int SPEED_MIN = 0;//in %
  //video instruction https://youtu.be/eqXaqRFAWrA

const int STOP=0;
const int RUN=1;
int motorState=RUN;//
int motorSpeed = 0;//between 0 to 100%.

void pushButton();
void setup() {
    //Robojax XY-GMOS MOSFET Motor driver code
  Serial.begin(9600);
  Serial.println("Robojax XY-GMOS Motor,  Arduino");
  pinMode(START_STOP_PIN, INPUT_PULLUP);
  pinMode(MOTOR_OUT_PIN, OUTPUT);
    //video instruction https://youtu.be/eqXaqRFAWrA

  
}

// the loop routine runs over and over again forever:
void loop() {

 pushButton();
 int potValue =analogRead(POT_PIN);
 int speedPercent = map(potValue, 0, 1023, 0, 100);

 if(motorState ==RUN)
 {
  motorControl(speedPercent);
 }else{
  stopMotor();
 }


  delay(500);
    //Robojax XY-GMOS MOSFET Motor driver code
      //video instruction https://youtu.be/eqXaqRFAWrA
}//loop end


/*
 * motorControl(int s)
 * @brief controls the motor with the value s
 * @param return nothing
 * @param "type" is character

 * on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
 */
void motorControl(int s)
{
    //Robojax LR7843 MOSFET Motor driver code
      //video instruction https://youtu.be/eqXaqRFAWrA
  int k = map(s, SPEED_MIN, SPEED_MAX, 0, 255);
  Serial.print("Speed: "); Serial.print(s);Serial.println("%");
  analogWrite(MOTOR_OUT_PIN, k);
}//motorControl



/*
 * stopMotor()
 * @brief stops the motor
 * @param return nothing
 * @param 

 * on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
 */
void stopMotor(){
    //Robojax XY-GMOS MOSFET Motor driver code
      //video instruction https://youtu.be/eqXaqRFAWrA
  analogWrite( MOTOR_OUT_PIN, 0);
  Serial.println("STOPPED");
}//stopMotor()



/*
 * pushButton()
 * @brief reads the push button
 * @param return nothing
 * @param 

 * on May 08, 2020 at 02:36 in Ajax, Ontario, Canada
 */
void pushButton()
{
  //Robojax XY-GMOS MOSFET Motor driver code
  //video instruction https://youtu.be/eqXaqRFAWrA
  if(digitalRead(START_STOP_PIN) ==LOW)
  {
    motorState =!motorState;
    delay(100);
  }
  
}//pushButton()


   

The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.