搜索代码

Using an IRF5305 E-Switch Module to Control Motor Speed

Using an IRF5305 E-Switch Module to Control Motor Speed

This article is on how to use the E-Switch module based on the IRF5305 MOSFET module. This module can act as a switch and can be controlled as a motor speed controller. All aspects of this module have been explained in the provided video at Robojax.com. Three different codes have been provided for different usages of this. Also, we have tested the module to see how much current it can handle under HIGH (24V) and at LOW (5V).

Image above shows MOSFET used as a switch.

Image above shows the MOSFET used to control a load connected at the Drain pin.

Image above shows the MOSFET used to control a load connected at the Source pin.

Schematic diagram of E-Switch based on IRF5305 MOSFET

图像

Basic Code to keep the IRF5305 Module always ON
Basic Code to keep the IRF5305 Module always ON
Basic Code to keep the IRF5305 Module always ON
Basic Code to keep the IRF5305 Module always ON
Basic Code to keep the IRF5305 Module always ON
Basic Code to keep the IRF5305 Module always ON
Schematic diagram of an E-switch based on the IRF5305 MOSFET
Schematic diagram of E-Switch based on IRF5305 Mosfet
156-Basic code to keep the IRF5305 module always on
语言: C++
/*
 * This is an Arduino sketch for a tutorial video 
 * explaining the 5305 MOSFET used as a switch 
 * This sketch turns the MOSFET ON and keeps it ON forever
 * 
 * Written by Ahmad Shamshiri on Sep 12, 2018 in Ajax, Ontario, Canada
 * For Robojax.com
 * Watch instruction video for this code: https://youtu.be/eAANkWDvusU
 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
 */
int loadPin =9;// load pin

  
void setup() {
  // Robojax.com demo
  pinMode(loadPin,OUTPUT);
  Serial.begin(9600);
  Serial.println("Robojax Demo"); 

}

void loop() {
  // Robojax.com tutorial

  digitalWrite(loadPin, HIGH);
 while(1);// wait forever


}
157-Basic code to keep the IRF5305 module always on
语言: C++
/*
 * This is an Arduino sketch for a tutorial video 
 * explaining the 5305 MOSFET used as a switch 
 * This sketch turns the MOSFET ON for 3 seconds then turns it OFF for 3 seconds.
 * 
 * Written by Ahmad Shamshiri on Sep 12, 2018 at 17:36 in Ajax, Ontario, Canada
 * For Robojax.com
 * Watch the instruction video for this code: https://youtu.be/eAANkWDvusU
 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
 */
int cont = HIGH;
int loadPin = 9; 
void setup() {
  // Robojax.com demo
  pinMode(loadPin,OUTPUT);
  Serial.begin(9600);
  Serial.println("Robojax Demo");
  

}

void loop() {
  // Robojax.com tutorial

 
  if(cont == HIGH)
  {
    Serial.println("OUTPUT is HIGH");
    digitalWrite(loadPin,HIGH);
    delay(3000);
    cont = LOW;
  }else{
    Serial.println("OUTPUT is LOW");
    digitalWrite(loadPin,LOW);
    delay(3000);
    cont = HIGH;   
  }

}
158-Basic code to keep the IRF5305 module always on
语言: C++
/*
 * This is an Arduino sketch for a tutorial video 
 * explaining the 5305 MOSFET used as a switch 
 * This sketch will control the speed of a motor or the intensity of a light using PWM
 * 
 * Written by Ahmad Shamshiri on Sep 12, 2018 at 23:23 in Ajax, Ontario, Canada
 * For Robojax.com
 * Watch the instruction video for this code: https://youtu.be/eAANkWDvusU
 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.
 */
int motorPin =9;// pin to connect to motor module
int mSpeed = 0;// variable to hold speed value
int mStep = 15;// increment/decrement step for PWM motor speed
  
void setup() {
  // Robojax.com demo
  pinMode(motorPin,OUTPUT);// set mtorPin as output
  Serial.begin(9600);// initialize serial motor
  Serial.println("Robojax Demo");
  

}

void loop() {
  // Robojax.com tutorial

analogWrite(motorPin, mSpeed);// send mSpeed value to motor
    Serial.print("Speed: ");
    Serial.println(mSpeed);// print mSpeed value on Serial monitor (click on Tools->Serial Monitor)
  mSpeed = mSpeed + mStep;
  // See the video for details.
  if (mSpeed <= 0 || mSpeed >= 255) {
    mStep = -mStep;
  }  

delay(200);

}

资源与参考

尚无可用资源。

文件📁

没有可用的文件。