Projects / Haptic pattern sampler

Haptic pattern sampler

Beginner1 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOBC547

    Check the transistor legs

    Collector, base, emitter from the datasheet.

  2. NANOBC547

    Wire the motor, diode and transistor

    Diode stripe to the 5 volt side.

  3. NANO

    Wire the button

    D2 to GND.

  4. NANO

    Upload and open the serial monitor at 9600

    Pattern 0 starts at once.

  5. NANO

    Feel pattern 0

    A double beat like a heartbeat.

  6. NANO

    Press the button for the others

    Ramp, pulse, knock and steady.

  7. NANO

    Change MAX_PWM

    Feel the difference in strength.

In short

How do you build a haptic pattern sampler?

A coin vibration motor plays five buzz patterns through a transistor and a button: a heartbeat, a ramp, a pulse, a knock and a steady buzz. You feel how timing and strength change the message. You need Arduino Nano, Vibration motor (coin type), BC547 NPN transistor, Resistor 1 kΩ, Signal Diode 1N4148, Tactile push button 6 mm, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
8

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Nano D91 kilohm resistor to the transistor baseSwitch signal
Transistor emitterNano GNDCommon ground
Motor one wireNano 5VMotor supply
Motor other wireTransistor collectorSwitched side
1N4148 diodeAcross the motor, stripe (cathode) to 5V, other end to the collectorCatches the kick when the motor stops
Button leg 1Nano D2Pattern select
Button leg 2Nano GNDPressing joins D2 to ground

Code

A coin vibration motor is a tiny motor with an off-centre weight, and you feel it rather than hear it. The Nano pin cannot drive it directly, so a BC547 transistor does the switching, with a 1 kilohm resistor in the base line. A diode across the motor catches the voltage spike that appears when the motor stops, so check its stripe goes to the 5 volt side. The sketch keeps the PWM to about 3 volts average, which suits a 3 volt motor. Press the button to step through five patterns, and notice that the same motor can feel like a heartbeat, a knock or a steady buzz purely from the timing and strength. The program only moves one motor and records nothing. Tape the motor to your wrist or hold it, but never put it in your mouth or ear, and keep the wires away from anything that can pull on it. Think about which pattern would suit a quiet alert and which a stronger warning.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const uint8_t MOTOR_PIN = 9;
const uint8_t BUTTON_PIN = 2;
const uint8_t MAX_PWM = 150;            // about 3 V average, kind to a 3 V coin motor
int pattern = 0;
const int PATTERNS = 5;

void buzz(uint8_t level, int ms) {
  analogWrite(MOTOR_PIN, level);
  delay(ms);
  analogWrite(MOTOR_PIN, 0);
}

void playPattern(int p) {
  switch (p) {
    case 0:                              // heartbeat: two beats and a rest
      buzz(MAX_PWM, 120); delay(120);
      buzz(MAX_PWM, 120); delay(700);
      break;
    case 1:                              // ramp: gentle to strong
      for (int level = 40; level <= MAX_PWM; level += 22) { buzz(level, 100); delay(20); }
      delay(500);
      break;
    case 2:                              // pulse: long buzz, long rest
      buzz(MAX_PWM, 500); delay(500);
      break;
    case 3:                              // knock: three quick taps
      for (int i = 0; i < 3; i++) { buzz(MAX_PWM, 60); delay(100); }
      delay(600);
      break;
    case 4:                              // steady buzz
      buzz(MAX_PWM / 2, 800);
      delay(300);
      break;
  }
}

void setup() {
  pinMode(MOTOR_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  playPattern(pattern);
  if (digitalRead(BUTTON_PIN) == LOW) {
    pattern = (pattern + 1) % PATTERNS;
    Serial.print("Pattern ");
    Serial.println(pattern);
    delay(300);
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Pattern 0Two beats and a rest
Pattern 1Buzz that grows stronger
Pattern 3Three short taps
Button pressMoves to the next pattern
Lower MAX_PWMA gentler buzz

If it does not work

Motor never moves

Check the transistor leg order and the base resistor.

Motor stays on

Check the base is not wired to 5V.

Transistor feels warm

Disconnect, check the collector and emitter.

Weak buzz

Raise MAX_PWM a little.

Button skips patterns

Press briefly.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the haptic pattern sampler?

Arduino Nano, Vibration motor (coin type), BC547 NPN transistor, Resistor 1 kΩ, Signal Diode 1N4148, Tactile push button 6 mm, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the haptic pattern sampler take to build?

About 60 minutes for a beginner maker, in 7 steps.

How do I know the haptic pattern sampler works?

Pattern 0: Two beats and a rest. Pattern 1: Buzz that grows stronger. Pattern 3: Three short taps.

Motor never moves: what should I check?

Check the transistor leg order and the base resistor.

Motor stays on: what should I check?

Check the base is not wired to 5V.

Transistor feels warm: what should I check?

Disconnect, check the collector and emitter.

Weak buzz: what should I check?

Raise MAX_PWM a little.