# (Example 1) Controlling a Single LED

{% hint style="success" %}
The **HUENIT AI Camera** has a total of **50 LEDs**, numbered **from 0 to 49**.\
Each individual **LED consists of three components**:

* **R (Red)**
* **G (Green)**
* **B (Blue)**

💡 **R, G, and B values can be set between 0 and 255.**
{% endhint %}

#### **Example Code**

(Example) Turn on **LED #0** with **R: 200, G: 100, B: 100**

<figure><img src="https://1881188396-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FauX5vWu2xzL5b4Cvif21%2Fuploads%2FwzRuBb6UhQpxQttu5HZh%2Fimage.png?alt=media&#x26;token=925e41fe-a710-487b-83b4-d9cc4ad00181" alt=""><figcaption></figcaption></figure>

***

### :bell: **Block Explanation**

**1. \[ Set num ( ) LED as RGB : ( ) ] Block**

* This block is used to set **R, G, and B values** for a specific **LED position**.

<figure><img src="https://1881188396-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FauX5vWu2xzL5b4Cvif21%2Fuploads%2FFe9tqfUhxzN6Tbzo0QS4%2Fimage.png?alt=media&#x26;token=e93a2732-d22d-47af-b54f-22755e0d7671" alt=""><figcaption></figcaption></figure>

✅ **(1-1) Setting Custom R, G, B Values**

* Users can manually input values **between 0 and 255** for **R, G, and B**.

<figure><img src="https://1881188396-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FauX5vWu2xzL5b4Cvif21%2Fuploads%2Fgv6YHhT403zNgP7U1fyb%2Fimage.png?alt=media&#x26;token=b5ff5228-e6c5-49d8-941d-58d3e261807a" alt=""><figcaption></figcaption></figure>

✅ **(1-2) Using Predefined Colors**

* Instead of manually entering values, users can choose from **preset color values**.

<figure><img src="https://1881188396-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FauX5vWu2xzL5b4Cvif21%2Fuploads%2F3Jn6DnTcn9riZV8MyI5N%2Fimage.png?alt=media&#x26;token=692a0e50-0dde-44fd-908e-ee64bbab53dc" alt=""><figcaption></figcaption></figure>

***

**2. \[ LED On ] Block**

* This block **activates** the LED with the **assigned color settings**.

<figure><img src="https://1881188396-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FauX5vWu2xzL5b4Cvif21%2Fuploads%2FOC3x5h7v9P8kFifX49Gg%2Fimage.png?alt=media&#x26;token=db471343-274a-4582-bb52-068c51c68952" alt=""><figcaption></figcaption></figure>

***

#### ​:warning:​**Important Notes** <a href="#undefined-2" id="undefined-2"></a>

* Only blocks **listed under the \[Start] block** in the **Event Block category** will be executed.
* **If the \[LED On] block is missing, the LED will not turn on.**

#### &#x20;<a href="#undefined-2" id="undefined-2"></a>
