Seeeduino XIAO PWM and IRF520 motor driver module

I have an IRF520 motor driver module that I would want to use with my Seeeduino XIAO. The IRF520 motor driver module has 3 pins : VCC, GND and SIGNAL. The signal pin is normally connected to a PWM pin and it is used to set the motor speed. I wrote the following simple program:

#define MOTOR_PIN 1

void setup() {
  pinMode(MOTOR_PIN,OUTPUT);
  analogWrite(MOTOR_PIN, 255);
}

void loop() {}

It works on the Arduino Uno, but not on the Seeeduino XIAO. Searching the forums (this thread), I found that Seeeduino has a specific void pwm(uint32_t outputPin, uint32_t frequency, uint32_t duty) function. I tried replacing analogWrite(MOTOR_PIN, 255) with this pwm function (I tried setting different frequencies), but it didn't work either. How can I make it work?

Is the Seeeduino XIAO a 3,3V device? The IRF520 is not a logic level MOSFET so you are lucky that it will turn on enough to drive the motor with 5V on the gate from a 5V Uno. 3.3V is just not enough voltage to turn that MOSFET on.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.