1e41f4b71Sopenharmony_ci# @system.vibrator (Vibrator) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **Vibrator** module provides APIs for controlling LED lights and vibrators. You can use the APIs to query the LED light list, turn on and off the LED light, query the vibrator list, query the vibrator effect, and trigger and turn off the vibrator. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciMisc devices refer to LED lights and vibrators on devices. LED lights are mainly used for indication (for example, indicating the charging state) and blinking (such as tri-colored lights). Vibrators are mainly used in scenarios such as the alarm clock, power-on/off, and incoming call vibration. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci> **NOTE** 9e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. 10e41f4b71Sopenharmony_ci> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.vibrator`](js-apis-vibrator.md) instead. 11e41f4b71Sopenharmony_ci> - This module requires hardware support and can only be debugged on real devices. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## Modules to Import 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci```ts 18e41f4b71Sopenharmony_ciimport { Vibrator } from '@kit.SensorServiceKit'; 19e41f4b71Sopenharmony_ci``` 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## Vibrator.vibrate 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci vibrate(options?: VibrateOptions): void 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciTriggers device vibration. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.VIBRATE 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Sensors.MiscDevice.Lite 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Parameters** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 34e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | ---------- | 35e41f4b71Sopenharmony_ci| options | [VibrateOptions](#vibrateoptions) | No | Vibration options.| 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**Example** 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci```ts 40e41f4b71Sopenharmony_ciimport { Vibrator, VibrateOptions } from '@kit.SensorServiceKit'; 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_cilet vibrateOptions: VibrateOptions = { 43e41f4b71Sopenharmony_ci mode: 'short', 44e41f4b71Sopenharmony_ci success: () => { 45e41f4b71Sopenharmony_ci console.info('Succeed in vibrating'); 46e41f4b71Sopenharmony_ci }, 47e41f4b71Sopenharmony_ci fail: (data: string, code: number) => { 48e41f4b71Sopenharmony_ci console.info(`Failed to vibrate. Data: ${data}, code: ${code}`); 49e41f4b71Sopenharmony_ci }, 50e41f4b71Sopenharmony_ci complete: () => { 51e41f4b71Sopenharmony_ci console.info('completed in vibrating'); 52e41f4b71Sopenharmony_ci } 53e41f4b71Sopenharmony_ci}; 54e41f4b71Sopenharmony_ciVibrator.vibrate(vibrateOptions); 55e41f4b71Sopenharmony_ci``` 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci## VibrateOptions 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ciDefines the vibration options. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.VIBRATE 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Sensors.MiscDevice.Lite 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 66e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ------------------------------------------------------------ | 67e41f4b71Sopenharmony_ci| mode | string | No | Vibration mode. The value **long** indicates long vibration, and **short** indicates short vibration. The default value is **long**.| 68e41f4b71Sopenharmony_ci| success | Function | No | Called when the vibrator data changes. | 69e41f4b71Sopenharmony_ci| fail | Function | No | Called when the API call fails. | 70e41f4b71Sopenharmony_ci| complete | Function | No | Called when the API call is complete. | 71