Example Code for Arduino-Vibration Motor
Control the vibration motor function.
Hardware Preparation
- 1 x Kitty's Flower
Software Preparation
Wiring Diagram
Vibration Motor is connected to pin D5 (refer to Board Overview for pin details).
Sample Code
#define VMPIN 5 //Vibration motor pin
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(VMPIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(VMPIN, HIGH); // turn the Motor on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(VMPIN, LOW); // turn the Motor off by making the voltage LOW
delay(1000); // wait for a second
}
Was this article helpful?
