This sample code shows you how to turn on and off the vibration motor.

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

This guide was first published on Mar 29, 2022. It was last updated on 2022-03-29 22:32:49 -0400.

This page (Sample Code for Vibration Motor) was last updated on Mar 29, 2022.

Text editor powered by tinymce.