> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/standard/sensor/ultrasonic/setultrasonicrgbled.md).

# setUltrasonicRgbled(id,red,green,blue)

控制超声波灯亮起设定颜色

### 参数

| 参数名   | 类型            | 描述                      |
| ----- | ------------- | ----------------------- |
| id    | unsigned char | 要控制的ID号，范围0\~10         |
| red   | int           | pwm设置RGB灯，红光亮度，范围0\~255 |
| green | int           | pwm设置RGB灯，绿光亮度，范围0\~255 |
| blue  | int           | pwm设置RGB灯，蓝光亮度，范围0\~255 |

### 例子

用uKitExplore v2板子控制1号超声波亮红色，400ms后亮紫色。

```c
#include "uKitExplore2.h"

void setup() {    
    Initialization();    
    setUltrasonicRgbled(1,255,0,0);    
    delay(400);    
    setUltrasonicRgbled(1,255,0,255);
}

void loop() {
}
```

{% hint style="info" %}
**关于亮度控制：**&#x82E5;想控制亮度也是可以的。只要保持颜色比例不变，值都相应减少就可以了。
{% endhint %}

用uKitExplore v2板子控制1号超声波亮红色（最亮），400ms后亮紫色（中等亮）。

```c
#include "uKitExplore2.h"
void setup() {    
    Initialization();    
    setUltrasonicRgbled(1,255,0,255);    
    delay(400);    
    setUltrasonicRgbled(1,127,0,127);
}

void loop() {
}
```
