LED Tower
LED Tower — is a strip consisting of 8 LEDs. Each LED can be controlled individually by changing its color. This module is perfect for creating indicators and light animations.
Basic usage
LEDTower(slot) -> NeoPixel
To create LEDTower object call LEDTower(slot).
Args:
slot (string | int | tuple)- slot label ("A", "B", "C", "D", "E", "F", "G", "H"), pin port (0, 2 and etc.), tuple (0, Pin.OUT)
Returns:
Return a NeoPixel object for the addressable-LED strip on slot.
from pibody import LEDTower
tower = LEDTower(8)
.write()
Sends the color data to the LED strip. Must be called after setting LED colors to apply changes.
tower.write()
.fill(color)
Use the .fill() function to make all 8 LEDs on the tower light up in a specific color.
tower.fill(tower.GREEN) # green
tower.write() # update state
Other Functions
Set one LED item
Sets the color of an individual LED. Accepts color tuple (r, g, b) or you can use preset colors.
tower[0] = tower.GREEN # green
tower[0] = (0, 255, 0) # also green
tower.write() # don't forget to update state
Get one LED item
Returns color tuple (r, g, b) of the LED.
led0 = tower[0]
print(led0)
API reference
LEDTower preset colors
| Title | Tuple |
|---|---|
| LEDTower.WHITE | (255, 255, 255) |
| LEDTower.BLACK | (0, 0, 0) |
| LEDTower.RED | (255, 0, 0) |
| LEDTower.GREEN | (0, 255, 0) |
| LEDTower.BLUE | (0, 0, 255) |
| LEDTower.YELLOW | (255, 255, 0) |
| LEDTower.CYAN | (0, 255, 255) |
| LEDTower.MAGENTA | (255, 0, 255) |
| LEDTower.ORANGE | (255, 165, 0) |
| LEDTower.PURPLE | (128, 0, 128) |
| LEDTower.PINK | (255, 192, 203) |
| LEDTower.LIME | (0, 255, 128) |
| LEDTower.TEAL | (0, 128, 128) |
| LEDTower.BROWN | (139, 69, 19) |