How to Use Arduino FET Drive Module for Motor Control with PWM
How to Use Arduino FET Drive Module for Motor Control with PWM
The FET Drive Module (MOSFET Drive Module) is a power switching board that uses the IRF540 MOSFET. It supports 3.7-27V and up to 10A current, making it effective for driving small DC motors. The module accepts PWM signals from Arduino, allowing you to control motor speed as well as turn it on and off.
Required Components
- Arduino UNO R3 with USB cable
- FET Drive Module PWM Switch Control Board (MOSFET IRF540)
- 5V DC Power Supply (Adapter or Regulated Supply)
- DC Motor 3-6V (vertical type)
- Motor propeller
- Jumper wires (M-M, M-F, F-F)
- Breadboard MB-102 (optional for neat wiring)
Wiring the Circuit
The wiring is divided into 3 main sections.
1. Connect Arduino to FET Module
| Arduino | FET Drive Module |
|---|---|
| Pin D5 | PWM pin |
| GND | GND |
Pin D5 on Arduino is PWM-capable, sending a duty-cycle signal to control the MOSFET’s switching behavior.
2. Connect 5V DC Power Supply to the Module
| 5V Power Supply | FET Drive Module |
|---|---|
| Positive (+) | DC+ |
| Negative (−) | DC− |
3. Connect DC Motor to the Module
| DC Motor | FET Drive Module |
|---|---|
| Red wire (+) | OUT+ |
| Black wire (−) | OUT− |
Attach the propeller to the motor shaft to clearly observe the rotation.
Arduino Code to Control Motor via Serial
The code below uses Serial Monitor to accept character commands. Send + to run the motor and - to stop it.
#define MOTOR_PWM 5 // Arduino PWM pin connected to FET Module PWM pin
void setup() {
Serial.begin(9600);
pinMode(MOTOR_PWM, OUTPUT);
digitalWrite(MOTOR_PWM, LOW); // Motor off at start
Serial.println("+ to start motor");
Serial.println("- to stop motor");
}
void loop() {
if (Serial.available() > 0) {
char command = Serial.read();
if (command == '+') {
digitalWrite(MOTOR_PWM, HIGH);
Serial.println("Motor running");
} else if (command == '-') {
digitalWrite(MOTOR_PWM, LOW);
Serial.println("Motor stopped");
}
}
}
How to use:
- Upload the code to Arduino UNO
- Open Serial Monitor (Tools → Serial Monitor)
- Set Baud Rate to 9600
- Type + and click Send → motor spins
- Type - and click Send → motor stops
Adjusting Motor Speed with PWM
If you want to vary speed instead of just on/off switching, replace digitalWrite with analogWrite using values from 0-255.
analogWrite(MOTOR_PWM, 128); // 50% PWM duty cycle, motor runs at half speed
For example, to make the motor speed increase or decrease based on values sent via Serial, you can extend the code accordingly.
Important Notes
- Connect the 5V DC power supply directly to the DC+ / DC- terminals of the Module. Do not use the 5V pin on Arduino for motor power, as the current is too high and may damage the board.
- Always double-check the polarity before powering on.
- If using a motor that requires higher voltage, use an appropriate power supply matching the motor’s specifications.
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย