Labs / Bipes + MicroPython / 8 Actuators (Outputs / Actuators)

8.4 How to indicate dice rolls? Build a small vibration feedback device! โ€”โ€” Vibration motor module based on MOSFET

Author: Li Zisheng ยท Source: FreakStudio open documentation ยท License: CC BY 4.0

Contents

Young makers, today let's unlock an "interactive vibrating gadget" ๐Ÿ“ณ!

The vibration when your phone receives a message, the haptic feedback from a game controller, and the alert vibration from a smart band โ€” all of these are powered by tiny vibration motors. Today, weโ€™re going to get to know the module that can make your development board โ€œvibrateโ€ โ€” the MOSFET-based vibration motor module โœจ, which delivers clear haptic vibration feedback for your development board and adds a tangible, tactile dimension to your projects!

1. Module Introduction

Want to make your development board vibrate just like a mobile phone? This module is your perfect go-to tool!

It is an execution-type output module: its core is a MOS transistor (which can be understood as an "electronic switch"). The development board only needs to output a low-current control signal, and the MOS transistor can drive the vibration motor to rotate, generating a noticeable vibration effect. Since the current required by the motor is larger than what the pins of the development board can supply, the MOS transistor acts like a "bridge" โ€” it uses a small signal to control a large current, which not only protects the development board but also enables the motor to vibrate stably.

Compared with ordinary direct-drive motors, it has the following characteristics:

In graphical programming, these blocks are commonly used for vibration motors:

In practical projects, it is often used for the following purposes:

Popular Science: What is a MOSFET?

A MOSFET acts like an "electronic switch": the pins of the development board only need to output a very small current (such as a high level) to turn the MOSFET "on", allowing a large current to flow to the motor and drive it to rotate; when a low level is output, the MOSFET turns "off" and the motor stops running. This not only ensures the safety of the development board but also enables the motor to work properly.

2. Wiring Instructions

To get the motor "vibrating", the first step remains the same โ€”โ€” connect the module correctly!

8.4 How to indicate dice rolls? Build a small vibration feedback device! โ€”โ€” Vibration motor module based on MOSFET

We connect the MOSFET-based vibration motor module to the digital interface DIO0 of the development board, and the corresponding relationship is as follows:

Development Board Pins

Module Pins

Description

Pin 6

DOUT

Motor control signal input pin

Pin 7

NC

-

๐Ÿ“Œ Note

3. Example: Control the motor to vibrate for 5 seconds

Experiment Objective: To achieve the effect of "automatically stop after vibrating for 5 seconds": start the motor and print "Start vibrating", stop the motor and print "Stop vibrating" after 5 seconds, so as to intuitively understand the control logic of the motor.

Life-related Tip: When your phone receives a WeChat message, it vibrates for a few seconds and then stops โ€” thatโ€™s a similar control logic. Now letโ€™s make a "vibration reminder" ourselves!

The graphical program is as follows:

8.4 How to indicate dice rolls? Build a small vibration feedback device! โ€”โ€” Vibration motor module based on MOSFET

Building Block Assembly Steps:

  1. Starter Motor
    • Drag in the set output pin block;
    • Selected Pin: Pin 9 / GPIO6;
    • Set to true โ†’ the motor starts vibrating;
  2. Print vibration prompt
    • Add print "Start vibrating" block to display the status in the terminal;
  3. Set vibration duration
    • Drag in the delay block and set it to 5 seconds โ†’ make the motor vibrate continuously for 5 seconds;
  4. Stop the motor
    • Drag in another set output pin block;
    • Pin Selection Pin 9 / GPIO6;
    • Set to false โ†’ the motor stops vibrating;
  5. Print stop prompt
    • Add print "Stop vibrating" block to indicate that the vibration has ended.

Experimental Effect:

Graphical blocks will be automatically converted into MicroPython code, and the running result will be output:

8.4 How to indicate dice rolls? Build a small vibration feedback device! โ€”โ€” Vibration motor module based on MOSFET

Directly importable building blocks:

Vibration.xml 2 KB

Tips

  1. If the motor does not vibrate:
    • Check if the correct pin is selected (Pin 9 / GPIO6) and whether the wiring is secure;
    • Confirm that the power supply of the module is normal and the motor is properly installed in place;
  2. The vibration intensity is adjustable:
    • Some modules are equipped with potentiometers, which can be turned to adjust the vibration intensity of the motor;
  3. Advanced Gameplay:
    • When paired with a touch key module, it achieves the interactive effect of "vibrating as soon as touched and stopping immediately when released".
    • When paired with a light sensor, it can realize the function of "vibration reminder when the ambient light is dim".

โœจ Interactive Mini Quiz

  1. Think about it: Why do we need to use MOSFETs to drive a motor instead of directly connecting it to the pins of the development board?
  2. Try it out: Change the delay time from 5 seconds to 2 seconds and see how the vibration duration changes; then change it to 10 seconds to experience different vibration feedback.

Summary

  1. The MOSFET-based vibration motor module is an actuator-type output module that drives the motor via a MOSFET to generate vibration;
  2. Its core principle is to use a small current to control a large current, which not only protects the development board but also enables the motor to operate stably.
  3. The basic usage is simple control following the sequence of "start โ†’ delay โ†’ stop", while the advanced usage enables interactive vibration in coordination with sensors;
  4. It is an interesting module that adds "haptic feedback" to projects, making it ideal for interactive toys and reminder devices.