可尋址LED#

介紹#

可尋址 LED 是一種可編程的 RGB LED 燈條設備,它連接到 3 線端口,並允許您控制單個 LED(例如 WS2812/“NeoPixel” 型)以顯示自訂顏色和圖案。

本頁面使用 address_led 作為可尋址 LED 的範例名稱。您可以根據需要將其替換為您自己配置的名稱。

以下是可用方法清單:

  • set – 設定可尋址 LED 燈條的顏色。

  • clear – 關閉整個可尋址 LED 燈條。

建構函式 – 手動初始化和配置可尋址 LED。

set#

set 將可尋址 LED 燈條設定為提供的值。

Usage:
address_led.set(data, offset)

參數

描述

data

包含 list 的 Color 值。其中包括 預定義顏色、十六進位整數 和 網頁顏色。

offset

可選。 LED 的起始索引,從 0 開始。

# Create a sequence of colors: Red, Green, Blue
color_list = [Color(0xFF0000), Color(0x00FF00), Color(0x0000FF)]

# Set the Addressable LED to the color_list sequence
address_led.set(color_list)

clear#

clear 關閉整個可尋址 LED 燈條。

Usage:
address_led.clear()

參數

描述

此方法沒有參數。

建構函數#

建構函式用於建立 AddressableLed 對象,這些對像是配置可尋址 LED 所必需的。

AddressableLed#

AddressableLed 建立一個可尋址 LED。

Usage:
AddressableLed(port)

範圍

描述

port

The 3-Wire Port that the Addressable LED strip is connected to:

  • On the V5 Brain – brain.three_wire_port.x where x is the number of the port.
  • On a 3-Wire Expander – expander.a where expander is the name of the expander instance.

# Create an Addressable LED in Port A
address_led = AddressableLed(brain.three_wire_port.a)