1# @ohos.brightness (Screen Brightness) (System API) 2 3The **brightness** module provides an API for setting the screen brightness. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - The APIs provided by this module are system APIs. 10 11## Modules to Import 12 13```js 14import brightness from '@ohos.brightness'; 15``` 16 17## brightness.setValue 18 19setValue(value: number): void 20 21Sets the screen brightness. 22 23**System API**: This is a system API. 24 25**System capability**: SystemCapability.PowerManager.DisplayPowerManager 26 27**Parameters** 28 29| Name| Type | Mandatory| Description | 30| ------ | ------ | ---- | ----------------------- | 31| value | number | Yes | Brightness value. Value range: 0 to 255. The value of this parameter must be a number.| 32 33**Error codes** 34 35For details about the error codes, see [Screen Brightness Error Codes](errorcode-brightness.md). 36 37| ID | Error Message | 38|---------|---------| 39| 4700101 | Failed to connect to the service. | 40| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 41| 202 | Permission verification failed. A non-system application calls a system API. | 42 43**Example:** 44 45```js 46try { 47 brightness.setValue(128); 48} catch(err) { 49 console.error('set brightness failed, err: ' + err); 50} 51``` 52 53## brightness.setValue<sup>11+</sup> 54 55setValue(value: number, continuous: boolean): void 56 57Sets the screen brightness. This API is used for continuous brightness adjustment. To achieve a better performance, set **continuous** to **true** when you start, and set it to **false** after you finish. 58 59**System API**: This is a system API. 60 61**System capability**: SystemCapability.PowerManager.DisplayPowerManager 62 63**Parameters** 64 65| Name| Type | Mandatory| Description | 66| ------ | ------ | ---- | ----------------------- | 67| value | number | Yes | Brightness value. Value range: 0 to 255. The value of this parameter must be a number.| 68| continuous | boolean | Yes | Whether the luminance adjustment is continuous. The value of this parameter must be of the Boolean type.| 69 70**Error codes** 71 72For details about the error codes, see [Screen Brightness Error Codes](errorcode-brightness.md). 73 74| ID | Error Message | 75|---------|---------| 76| 4700101 | Failed to connect to the service. | 77| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 78| 202 | Permission verification failed. A non-system application calls a system API. | 79 80**Example:** 81 82```js 83try { 84 brightness.setValue(128, true); 85} catch(err) { 86 console.error('set brightness failed, err: ' + err); 87} 88``` 89