2017年4月13日 星期四

[WS2812] 8-Bit 2812 RGB LED

傳統方式要控制多顆 RGB LED 在電路接線和程式控制方面是非常煩雜的,然而使用內建 WS2812 晶片的 RGB LED 卻是簡單又方便,不管你要控制幾顆 RGB LED,都只要使用 Arduino 3 支腳位就足夠了。

在這兒我使用 2 串 8-Bit RGB LED 燈條來作示範



準備材料

1. 8-Bit 2812 RGB LED *2



2. 排針 4P(腳距2.54mm) *2
3. 排母 4P(腳距2.54mm) *2


4. 杜邦線母母頭 3P *1
5. Arduino Uno or Nano *1


焊接

1. 將排針焊到燈條的 DI 端。
2. 將排母焊到燈條的 DO 端。
3. 如步驟1 & 2 焊接另一燈條。



電路接線

1. 將兩只燈條連接起來,也就是將燈條的公排針插入另一燈條的母排針。
2. 用杜邦線依下表將 Arduino 與燈條連接起來:

Arduino      燈條
5V               VDC
Gnd             Gnd
D6               DI


下載函式庫

1. 點選右側網址下載函式庫 https://github.com/adafruit/Adafruit_NeoPixel
2. 將下載的檔案解壓縮,複製到 Arduino IDE 的 libraries 資料夾裏。
3. 更改名稱為「Adafruit_NeoPixel」。


執行範例程式

1. 啟動 Arduino IDE。
2. 點擊「檔案」>「範例」>「Adafruit_NeoPixel」>「strandtest」。
3. 找到這一行
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
修改為
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);

4. 上傳程式。


影片



採購資訊

1. 8-Bit 2812 RGB LED http://goods.ruten.com.tw/item/show?21715791439863
2. 排針 http://goods.ruten.com.tw/item/show?21646385415847
3. 排母 http://goods.ruten.com.tw/item/show?21646384889087
4. 杜邦線 母母頭 http://goods.ruten.com.tw/item/show?21629159825718
5. Arduino Nano http://goods.ruten.com.tw/item/show?21642069565073
6. Arduino Nano & Uno 兩用擴展板 http://goods.ruten.com.tw/item/show?21628077602506


















3 則留言: