NeoPixel(WS2812) JP: 두 판 사이의 차이

아두위키 : Arduwiki
(새 문서: center|class=coders100 A single LED that can display multiple colors by adjusting RGB values, with each LED individually controllable by a controller. In the text, two models were used: a circular one with 7 LEDs and a linear one with 8 LEDs. The terminals total either 6 or 8, with the 6-terminal version comprising (IN, 2x VCC, 2x GND, OUT), and the 8-terminal version adding 2 more GNDs to the 6-terminal setup. Connecting the OUT ter...)
 
잔글편집 요약 없음
 
(같은 사용자의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[File:네오픽셀대표이미지1.jpg|center|class=coders100]]
{{#seo:|title=アルドゥウィキ:アルドゥイーノ ネオピクセル(WS2812)ガイド|title_mode=append|keywords=アルドゥイーノ, 情報科学, メーカー学習, パフォーマンス評価, ネオピクセル(WS2812), アルドゥイーノプロジェクト, キャップストーンプロジェクト, アルドゥイーノサンプルコード|description=アルドゥイーノでネオピクセル(WS2812)を制御する方法(基本情報、回路、サンプルコード)を紹介します。情報科学とメーカー授業で活用できます。}}[[File:네오픽셀대표이미지1.jpg|center|class=coders100]]
A single LED that can display multiple colors by adjusting RGB values, with each LED individually controllable by a controller.




In the text, two models were used: a circular one with 7 LEDs and a linear one with 8 LEDs.
単一のLEDがRGB値を調整して複数の色を表示でき、各LEDはコントローラーによって個別に制御可能です。


The terminals total either 6 or 8, with the 6-terminal version comprising (IN, 2x VCC, 2x GND, OUT), and the 8-terminal version adding 2 more GNDs to the 6-terminal setup.
本文では、7つのLEDを持つ円形モデルと8つのLEDを持つ直線型モデルが使用されました。


Connecting the OUT terminal of a NeoPixel to the IN terminal of the next allows for controlling multiple NeoPixels with just one pin on the board.
端子数は6つまたは8つで、6端子バージョンは(IN、2x VCC、2x GND、OUT)で構成され、8端子バージョンは6端子設定に2つのGNDを追加します。


== '''Specifications''' ==
NeoPixelのOUT端子を次のNeoPixelのIN端子に接続することで、ボードの1つのピンで複数のNeoPixelを制御できます。


* Operating Voltage: 5V
* Current per LED: 20mA ~ 80mA


== '''Required Hardware''' ==
== '''仕様''' ==
* 動作電圧: 5V
* LEDあたりの電流: 20mA ~ 80mA


== '''必要なハードウェア''' ==
* NeoPixel
* NeoPixel
* Arduino UNO
* Arduino UNO
* UNO cable
* UNOケーブル
* M-M cable(6ea)
* M-Mケーブル(6本)
* F-M cable(3ea)
* F-Mケーブル(3本)
 


== '''Connection (M-M and F-M cables were soldered for connection to the NeoPixel)''' ==
== '''接続(M-MとF-MケーブルはNeoPixelへの接続のためにはんだ付けされました)''' ==


* NeoPixel to Arduino Connection
* NeoPixelとArduinoの接続
{| class="wikitable"
{| class="wikitable"
|+
|+
39번째 줄: 41번째 줄:
|GND
|GND
|}
|}
* Connection between the 1st and 2nd NeoPixel (apply the same method to add more NeoPixels):
 
 
* 1つ目と2つ目のNeoPixelの接続(他のNeoPixelを追加する際も同じ方法を適用)
{| class="wikitable"
{| class="wikitable"
|+
|+
!1st NeoPixel
!1つ目のNeoPixel
!2nd NeoPixel
!2つ目のNeoPixel
|-
|-
|OUT
|OUT
56번째 줄: 60번째 줄:
[[File:WS2812 회로.png|center|class=coders100]]
[[File:WS2812 회로.png|center|class=coders100]]


== '''Library''' ==
== '''ライブラリ''' ==
* Adafruit NeoPixel ([[Arduino Libraries]])


* Adafruit NeoPixel ([[Arduino Libraries]])


== '''예제 코드''' ==
== '''サンプルコード''' ==
<syntaxhighlight lang="c++" line="1">
<syntaxhighlight lang="c++" line="1">
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoPixel.h>


// Using pin number 7
// ピン番号7を使用
#define PIN       7
#define PIN 7
// Number of pixels
// ピクセル数
#define NUMPIXELS 15
#define NUMPIXELS 15
// Brightness level
// 明るさレベル
#define bright 255
#define bright 255
#define dly 10000
#define dly 10000
// Create a NeoPixel object for control
// NeoPixelオブジェクトを作成
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
void setup() {
     // Start NeoPixel
     // NeoPixelを開始
     neo.begin();
     neo.begin();
     // Set NeoPixel brightness
     // NeoPixelの明るさを設定
     neo.setBrightness(bright);
     neo.setBrightness(bright);
     // Initialize NeoPixel
     // NeoPixelをクリア
     neo.clear();
     neo.clear();
     // Apply NeoPixel settings
     // NeoPixel設定を適用
     // Settings are applied internally until .show() is executed.
     // 内部的に設定が適用されるまで.show()が実行されない。
     // When .show() runs, the commands applied internally are executed on the LEDs.
     // .show()が実行されると、内部的に適用されたコマンドがLEDに反映されます。
     neo.show();
     neo.show();
}
}
89번째 줄: 93번째 줄:
void loop()
void loop()
{
{
     // Turn LEDs white
     // LEDを白にする
     for (int i = 0; i < 15; i++)
     for (int i = 0; i < 15; i++)
     {
     {
124번째 줄: 128번째 줄:
</syntaxhighlight>
</syntaxhighlight>


=== Execution Result ===
 
=== 実行結果 ===
[[File:Ws2812 시연.png|center|class=coders100]]
[[File:Ws2812 시연.png|center|class=coders100]]

2025년 3월 20일 (목) 19:51 기준 최신판


単一のLEDがRGB値を調整して複数の色を表示でき、各LEDはコントローラーによって個別に制御可能です。

本文では、7つのLEDを持つ円形モデルと8つのLEDを持つ直線型モデルが使用されました。

端子数は6つまたは8つで、6端子バージョンは(IN、2x VCC、2x GND、OUT)で構成され、8端子バージョンは6端子設定に2つのGNDを追加します。

NeoPixelのOUT端子を次のNeoPixelのIN端子に接続することで、ボードの1つのピンで複数のNeoPixelを制御できます。


仕様

  • 動作電圧: 5V
  • LEDあたりの電流: 20mA ~ 80mA


必要なハードウェア

  • NeoPixel
  • Arduino UNO
  • UNOケーブル
  • M-Mケーブル(6本)
  • F-Mケーブル(3本)


接続(M-MとF-MケーブルはNeoPixelへの接続のためにはんだ付けされました)

  • NeoPixelとArduinoの接続
NeoPixel Arduino
IN D7
VCC 5V
GND GND


  • 1つ目と2つ目のNeoPixelの接続(他のNeoPixelを追加する際も同じ方法を適用)
1つ目のNeoPixel 2つ目のNeoPixel
OUT IN
VCC VCC
GND GND

ライブラリ


サンプルコード

#include <Adafruit_NeoPixel.h>

// ピン番号7を使用
#define PIN 7
// ピクセル数
#define NUMPIXELS 15
// 明るさレベル
#define bright 255
#define dly 10000
// NeoPixelオブジェクトを作成
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
    // NeoPixelを開始
    neo.begin();
    // NeoPixelの明るさを設定
    neo.setBrightness(bright);
    // NeoPixelをクリア
    neo.clear();
    // NeoPixel設定を適用
    // 内部的に設定が適用されるまで.show()が実行されない。
    // .show()が実行されると、内部的に適用されたコマンドがLEDに反映されます。
    neo.show();
}

void loop()
{
    // LEDを白にする
    for (int i = 0; i < 15; i++)
    {
        neo.setPixelColor(i, 255, 255, 255);
    }
    neo.show();
    delay(500);

    // Turn LEDs red
    for (int i = 0; i < 15; i++)
    {
        neo.setPixelColor(i, 255, 0, 0);
    }
    neo.show();
    delay(500);

    // Turn LEDs green
    for (int i = 0; i < 15; i++)
    {
        neo.setPixelColor(i, 0, 255, 0);
    }
    neo.show();
    delay(500);

    // Turn LEDs blue
    for (int i = 0; i < 15; i++)
    {
        neo.setPixelColor(i, 0, 0, 255);
    }
    neo.show();
    delay(500);
}


実行結果