Vibrating motor

What is a vibration motor? How can it be used in your project?

Introduction

A vibration motor is a system that generates vibrations by means of a rotary, linear or electromagnetic mechanism.
In our case, we’ll be using a motor with a rotating mechanism. Its vibratory intensity is driven by the centrifugal force of the eccentric mass and the speed of rotation.

This motor is ubiquitous in telephones and video game controllers.
The vibration engine allows you to make your project vibrate, for example to vibrate a joystick, an alarm or to simulate the arrival of a notification.

Pins of the Vibration motors

The vibration motor has two pins:

  • Vcc: powers the motor. Must be connected to 5V or a controllable pin on the Arduino board.
  • GND: Connects to Arduino board ground.

Connect your motor

Now we’ll explain how to connect this vibrating motor to your Arduino board to make it work. Simply connect the vibrating motor to the 5V and GND pins on your Arduino board.

Turning the vibration motor on and off

To switch your vibration motor on and off, we’re going to use one of the controllable pins on the Arduino board. Here’s the new circuit diagram:

int moteur_vibration = 12; // Motor spindle to virabtion
 
void setup() {
 pinMode(moteur_vibration, OUTPUT ); // Output motor pin
}
 
void loop(){
 digitalWrite(moteur_vibration, HIGH); //Power up the motor
 delay(1000); // Pause for one second
 digitalWrite(moteur_vibration, LOW); // Switch motor off
 delay(1000);
}

Vary the motor speed

To regulate the current of your vibration motor, we’ll use the analogWrite function. This allows us to vary the motor voltage from 0V to 5V. The schematic remains identical to the one above.

int broche_moteur = 12; // motor spindle has vibration
 
void setup() { } 

void loop() { 
// We increase the value
 for (int Value = 0 ; Value <= 255; Value += 5) {
 analogWrite(pin_motor, Value);// We add the value assigned to the servomotor (From 0 to 255)
 delay(30); // Pause for 30 milliseconds
 }
 
// Now decrement from 255 to 0
 for (int Value = 255; Value >= 0; Value -= 5) {
 analogWrite(pin_motor, Value);// We add the value assigned to the servomotor (From 0 to 255)
 delay(30);// Pause for 30 milliseconds
 }
}