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