1# @ohos.multimodalInput.infraredEmitter (IR Management) 2 3The **infraredEmitter** module generates IR signals of the specified frequency and size, and queries the frequency range supported by the device. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9 10## Modules to Import 11 12```js 13import { infraredEmitter } from '@kit.InputKit'; 14``` 15 16## infraredEmitter.transmitInfrared<sup>15+</sup> 17 18transmitInfrared(infraredFrequency: number, pattern: Array<number>): void 19 20Generates IR signals at the specified frequency and level. 21 22**Required permissions**: ohos.permission.MANAGE_INPUT_INFRARED_EMITTER 23 24**System capability**: SystemCapability.MultimodalInput.Input.InfraredEmitter 25 26**Parameters** 27 28| Name | Type | Mandatory | Description | 29| -------- | ------------------------- | ---- | ---------------------------------------- | 30| infraredFrequency | number | Yes | IR frequency, in Hz.| 31| pattern | Array<number> | Yes | IR level signal, in μs. The value must be an even number within the value range of [0,1024].<br>For example, in the IR level signal array [100,200,300,400], 100 μs is a high-level signal, 200 μs is a low-level signal, 300 μs is a high-level signal, and 400 μs is a low-level signal.| 32 33**Error codes** 34 35For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 36 37| ID| Error Message | 38| -------- | ----------------- | 39| 201 | Permission denied. | 40| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. | 41 42**Example** 43 44```js 45try { 46 infraredEmitter.transmitInfrared(38000, [100, 200, 300, 400]); 47} catch (error) { 48 console.error(`transmitInfrared failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 49} 50``` 51 52## infraredEmitter.getInfraredFrequencies<sup>15+</sup> 53 54getInfraredFrequencies(): Array<InfraredFrequency> 55 56Queries the frequency range of IR signals supported by the mobile phone. 57 58**Required permissions**: ohos.permission.MANAGE_INPUT_INFRARED_EMITTER 59 60**System capability**: SystemCapability.MultimodalInput.Input.InfraredEmitter 61 62**Return value** 63 64| Parameter | Description | 65| ------------------- | ------------------- | 66| Array<[InfraredFrequency](#infraredfrequency15)> | Frequency range, including multiple groups of maximum and minimum frequencies.| 67 68**Error codes** 69 70For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 71 72| ID| Error Message | 73| -------- | ----------------- | 74| 201 | Permission denied. | 75 76**Example** 77 78```js 79try { 80 let frequencies = infraredEmitter.getInfraredFrequencies(); 81 console.log(`frequencies: ${JSON.stringify(frequencies)}`); 82} catch (error) { 83 console.error(`Get infrared frequencies failed, error: ${JSON.stringify(error, [`code`, `message`])}`); 84} 85``` 86 87## InfraredFrequency<sup>15+</sup> 88 89Defines the frequency range of IR signals. 90 91**System capability**: SystemCapability.MultimodalInput.Input.InfraredEmitter 92 93| Name | Type| Mandatory | Description | 94| -------------------------------- | ---- | ------ | ------ | 95| max | number | Yes| Maximum frequency, in Hz.| 96| min | number | Yes | Minimum frequency, in Hz.| 97