How to use a vibration motor with Arduino

  • avatar
  • 1.1K Views
  • 1 Like
  • 4 mins read

The integration of components with Arduino opens a world of possibilities. One often overlooked but incredibly useful component is the vibration motor. Vibration motors are compact, motorized devices designed to generate vibrations. This device, often found in smartphones and game controllers, can add a tactile dimension to your projects, providing physical feedback that enhances user experience. In this article, we'll explore the basics of vibration motors and explore into how you can effortlessly connect them to Arduino for a wide range of applications.

Components

arduino-nano

1x Arduino Nano (or another Arduino module)

$3.18

Buy now

mini-breadboard

1x Mini-breadboard

$1.17

Buy now

vibration-motor

1x Mini vibration motor

$0.38

Buy now

dupont

Dupont wires

$1.61

Buy now

Wiring schema

Connecting a vibration motor to an Arduino is a straightforward process, requiring minimal components. By connecting the motor to a digital pin on the Arduino you can control the intensity and duration of the vibrations.

Arduino Nano wiring with vibration motor

Note: the motor can be connected to Arduino Nano D3 or any other digital output pin.

Arduino code

To bring the project to life, we will need to incorporate code that dictates when and how the vibration motor activates. With just a few lines of code, you can program the Arduino to activate the vibration motor based on specific events or conditions, adding a dynamic, tactile element to your projects.

#define MOTOR_PIN 3

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

void loop()
{
// Turn vibration ON
digitalWrite(MOTOR_PIN, HIGH);
delay(1000);

// Turn vibration OFF
digitalWrite(MOTOR_PIN, LOW);
delay(1000);
}

With a bit of tinkering, you can fine-tune the vibration patterns, creating a nuanced and engaging user experience.

Conclusion

These compact devices bring a dynamic and immersive quality to user interfaces, making them more engaging and intuitive. By understanding the basics of vibration motors and mastering their connection with Arduino, you can create projects that not only look and sound great but also feel captivating in the hands of users.

Credits

Official GitHub: https://github.com/hibit-dev/vibration-motor

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month

We never send SPAM nor unsolicited emails

0 Comments

Leave a Reply

Your email address will not be published.

Replying to the message: View original

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.