beginnerChapter 19 of 4520 min

19. Vibration Motor

Learn to control the motor with digitalWrite() or analogWrite(); outcome: motor vibrates 0.5 s, stops 0.5 s, repeat; optional PWM for strength.

This lesson uses: Arduino UNO R3 board, TinkerBlock TK30 Vibration Motor module, jumper wires (or breadboard). Learn to control the motor with digitalWrite() or analogWrite(); outcome: motor vibrates 0.5 s, stops 0.5 s, repeat; optional PWM for strength.

1. Wiring

Connect TK30 Vibration Motor to Arduino:

  • GND → Arduino GND
  • VCC → Arduino 5V (it feeds the module's own 3.3 V regulator, which powers the motor; the motor gets about 3.3 V from 5V or 3V3 alike)
  • SIGNAL → Arduino D3 (PWM pin for speed control)
  • NC leave unconnected

TK30 wiring diagram

2. New sketch

  1. Arduino IDE: File → New (or Ctrl/Cmd + N) to create a blank sketch
  2. Confirm board and port are selected (same as Lesson 01)
  3. Type the code below into the default setup() and loop() yourself

3. Program structure

Same as last lesson: two fixed blocks setup() and loop().

  • setup(): Tell the board “pin 3 for motor”; start serial (optional); runs once.
  • loop(): Keep repeating “motor on → wait → motor off → wait → repeat”.

After uploading the motor will vibrate then stop in a loop; for strength control try the PWM code in the comments.

4. Code to write

Type the code below line by line into setup() and loop() (do not copy-paste; typing it yourself helps you remember):

#define MOTOR_PIN 3   // Vibration motor on D3

void setup() {
  pinMode(MOTOR_PIN, OUTPUT);   // D3 output for motor (PWM for speed)
  Serial.begin(9600);
  Serial.println("Vibration motor program started");
}

void loop() {
  // Method 1: digitalWrite (on/off only)
  digitalWrite(MOTOR_PIN, HIGH);   // Vibrate
  Serial.println("Motor vibrating...");
  delay(500);
  
  digitalWrite(MOTOR_PIN, LOW);    // Stop
  Serial.println("Motor stopped");
  delay(500);
  
  // Method 2: analogWrite for speed (optional, uncomment to try)
  // analogWrite(MOTOR_PIN, 128);   // 50% duty: may not start from rest
  // delay(500);
  // analogWrite(MOTOR_PIN, 255);   // 100% speed
  // delay(500);
  // analogWrite(MOTOR_PIN, 0);     // Stop
  // delay(500);
}

Program notes

Overall idea: Motor on PWM pin: digitalWrite(HIGH/LOW) = on/off; analogWrite(0–255) = vibration strength (higher duty cycle = stronger). This lesson uses digitalWrite for on/off loop; optionally try the analogWrite lines for speed control.

CodeIn this lesson
digitalWrite(MOTOR_PIN, HIGH/LOW)On/off vibration, no speed steps
analogWrite(MOTOR_PIN, 128)PWM: 0=off, 255=full, in-between=weaker. Below about 178 a stopped motor may not start: write 255 for 50 ms first

5. Hands-on

  1. After entering the code, click Verify (✓) to compile
  2. Click Upload (→) to upload to the board
  3. Feel TK30: vibrate 0.5 s, stop 0.5 s, repeat
  4. Try yourself:
    • Uncomment method 2 and use analogWrite() to control strength
    • Change delay() to change on/off time

Expected result: As in the figure.

Vibration motor effect

Proceed to Lesson 20.

6. Common issues

SymptomWhat to do
Motor not vibratingCheck TK30 wiring GND→GND, VCC→5V, SIGNAL→D3
Too weakTry analogWrite(MOTOR_PIN, 255) for max strength
Nothing at analogWrite(MOTOR_PIN, 128)The motor may not start from rest below about 178; write 255 for 50 ms, then 128

Edit this page — content/guides/tinkerblock-workshop/19-vibration-motor.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Vibration Motor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Projects and guides on the forum