# Programming with MicroPython: NeoPixel

### Import FutureBoard Library

Import the Library to make use of its functions.

```
from future import *
```

### 06: Neopixel

#### 1. Initiate a NeoPixel Strip

```
NeoPixel(pin, num)
```

Initiates a NeoPixel Strip with a number of LEDs on the selected pin.

Use P7 and 3 for the built-in LED Strip.

#### 2. Setting Color for 1 LED

```
setColor(i, color)
```

Parameter i denotes the id of the LED.

Neopixel accepts RGB value or built-in color names.

#### 3. Setting Color for All LED

```
setColorAll(color)
```

Neopixel accepts RGB value or built-in color names.

#### 4. Update Display

```
update()
```

Update the display to show the effects.

#### Sample Program

```
# Lights up LEDs then turns off

from future import *
import time
""" Available colours
RED=(255,0,0)
YELLOW=(255,255,0)
PINK=(255,105,180)
WHITE=(255,255,255)
BLACK=(0,0,0)
GREEN=(0,255,0)
BLUE=(0,0,255)
PURPLE=(148,0,211)
CYAN = (0,255,255) 
"""
np = NeoPixel('P7', 3)
color = [RED,GREEN,BLUE]
for i in range(3):
    np.setColorAll(color[i])
    np.update() #Update display
    time.sleep(1)
for i in range(3):
    np.setColor(i,BLACK)
    np.update() #Update display
    time.sleep(1)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sharinghub-eng.kittenbot.hk/main-controllers/futureboard/futureboard-micropython-programming-tutorial/programming-with-micropython-neopixel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
