ESP8266 and vibration sensor module

In this example we connect a vibration motor module to an ESP8266. This is the type of motor that you could find in a mobile phone which vibrates when you receive a text message for example

This is the module I bought


When the Logic level is HIGH, the motor is ON. When its LOW, the motor is OFF.

Connection

 

Wemos Mini Vibration motor
3v3 Vcc
Gnd Gnd
D4 In

Parts List

Here are the parts I used

Part name Link
Wemos Mini D1 mini – Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos
Vibration Motor Module PWM Vibration Motor Module DC Motor Phone Vibrator for Arduino UNO R3 MEGA2560 Electronic DIY Kit
Dupont cable Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire Dupont cablefor Arduino

 

Code

This is a simple example which simply switches the motor on for 1 second and off for 1 second

[codesyntax lang=”cpp”]

int motorPin = D4;    // vibration motor digital pin D4

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

void loop()  
{
    digitalWrite(motorPin, HIGH);
    delay(1000);
    digitalWrite(motorPin, LOW);
    delay(1000);
}

[/codesyntax]

Links

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here