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
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