---
title: "Vibration"
canonical_url: https://developer.repebble.com/pebbleos/docs/samples/drivers/vibe/
last_updated: 2026-11-17
sdk_version: 4.44
---
# Vibration

Source: https://developer.repebble.com/pebbleos/docs/samples/drivers/vibe/

This sample buzzes the vibration motor three times. Then, if its driver can brake, it buzzes three more times, each time driving the motor at the braking strength from `pbl_vibe_get_braking_strength()` for a moment before stopping it, which ends the buzz sooner.

On a watch, feel the difference between the two sets of pulses. The emulator’s simulated motor cannot brake.

Run:

`pbl samples samples/drivers/vibe`

Boards:

every board

## Sources

src/main.c

```
#include \<stdint.h\>#include \<stdio.h\>#include \<pbl/drivers/vibe.h\>#include \<pbl/kernel/delay.h\>#define PULSES 3#define PULSE\_MS 150#define PAUSE\_MS 350#define BRAKE\_MS 40static int prv\_pulse(int8\_t strength, int8\_t braking) {int ret;ret = pbl\_vibe\_start(VIBE, strength);if (ret != 0) {fprintf(stderr, "vibe: start failed (%d)\n", ret);return ret;}pbl\_sleep\_ms(PULSE\_MS);/\* Driving the motor against itself for a moment stops it sooner. \*/if (braking != VIBE\_STRENGTH\_OFF) {ret = pbl\_vibe\_start(VIBE, braking);if (ret != 0) {fprintf(stderr, "vibe: brake failed (%d)\n", ret);return ret;}pbl\_sleep\_ms(BRAKE\_MS);}ret = pbl\_vibe\_stop(VIBE);if (ret != 0) {fprintf(stderr, "vibe: stop failed (%d)\n", ret);}return ret;}int main(void) {int8\_t braking = pbl\_vibe\_get\_braking\_strength(VIBE);int ret;for (int i = 0; i \< PULSES; i++) {ret = prv\_pulse(VIBE\_STRENGTH\_MAX, VIBE\_STRENGTH\_OFF);if (ret != 0) {return ret;}printf("vibe: pulse %d\n", i + 1);pbl\_sleep\_ms(PAUSE\_MS);}if (braking == VIBE\_STRENGTH\_OFF) {printf("vibe: no braking\n");} else {for (int i = 0; i \< PULSES; i++) {ret = prv\_pulse(VIBE\_STRENGTH\_MAX, braking);if (ret != 0) {return ret;}printf("vibe: braked pulse %d, braking at %d\n", i + 1, braking);pbl\_sleep\_ms(PAUSE\_MS);}}printf("Sample done\n");return 0;}
```

## Output

```
vibe: pulse 1
vibe: pulse 2
vibe: pulse 3
vibe: (no braking|braked pulse 3, braking at -?\d+)
Sample done
```

Generated from PebbleOS [9e782207f](https://github.com/coredevices/pebbleos/commit/9e782207f53f8f1c02f7b13ea40cdc092d7bab3d). This page is maintained in the pebbleos repository: [docs/samples/drivers/vibe.md](https://github.com/coredevices/pebbleos/blob/9e782207f53f8f1c02f7b13ea40cdc092d7bab3d/docs/samples/drivers/vibe.md).
