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

아두위키 : Arduwiki
잔글편집 요약 없음
잔글편집 요약 없음
 
1번째 줄: 1번째 줄:
[[File:네오픽셀대표이미지1.jpg|center|class=coders100]]
[[File:네오픽셀대표이미지1.jpg|center|class=coders100]]
하나의 led로 RGB값을 조절하여 여러 색을 표현할 수 있는 LED입니다.
A single LED that can display multiple colors by adjusting RGB values, with each LED individually controllable by a controller.


또한 컨트롤러로 각 led를 개별적으로 제어 가능합니다.


In the text, two models were used: a circular one with 7 LEDs and a linear one with 8 LEDs.


본문에서는 원형(LED 7개), 직선형(LED 8개) 두 모델을 사용하였습니다.
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.


단자는 총 6개 혹은 8개이며 6개의 경우 (IN, VCC 2개, GND 2개, OUT)이며 8개의 경우는 기존 6개 단자에 GND 2개가 추가된 형태입니다.
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.


보드에 연결된 네오픽셀의 out단자에 다음 네오픽셀의 in 단자를 연결시키면 보드에 하나의 핀만 연결하여 사용할 수 있습니다.
== '''Specifications''' ==


== '''사양''' ==
* Operating Voltage: 5V
* Current per LED: 20mA ~ 80mA


* 작동 전압 : 5V
== '''Required Hardware''' ==
* 각 led당 20mA ~ 80mA
 
== '''필요 하드웨어''' ==


* NeoPixel
* NeoPixel
24번째 줄: 22번째 줄:
* F-M cable(3ea)
* F-M cable(3ea)


== '''연결(M-M, F-M cable을 납땜하여 neopixel에 연결하였음)''' ==
== '''Connection (M-M and F-M cables were soldered for connection to the NeoPixel)''' ==
 
* 네오픽셀, 아두이노 간 연결


* NeoPixel to Arduino Connection
{| class="wikitable"
{| class="wikitable"
| colspan="1" rowspan="1" |neopixel
|+
| colspan="1" rowspan="1" |arduino
!NeoPixel
!Arduino
|-
|-
| colspan="1" rowspan="1" |IN
|IN
| colspan="1" rowspan="1" |D7
|D7
|-
|-
| colspan="1" rowspan="1" |VCC
|VCC
| colspan="1" rowspan="1" |5V
|5V
|-
|-
| colspan="1" rowspan="1" |GND
|GND
| colspan="1" rowspan="1" |GND
|GND
|}
|}
 
* Connection between the 1st and 2nd NeoPixel (apply the same method to add more NeoPixels):
* 1<sup>st</sup> 네오픽셀, 2<sup>nd</sup> 네오픽셀간 연결(이후 네오픽셀을 더 추가하더라도 동일한 방식으로 적용)
 
{| class="wikitable"
{| class="wikitable"
| colspan="1" rowspan="1" |1st neopixel
|+
| colspan="1" rowspan="1" |2nd neopixel
!1st NeoPixel
!2nd NeoPixel
|-
|-
| colspan="1" rowspan="1" |OUT
|OUT
| colspan="1" rowspan="1" |IN
|IN
|-
|-
| colspan="1" rowspan="1" |VCC
|VCC
| colspan="1" rowspan="1" |VCC
|VCC
|-
|-
| colspan="1" rowspan="1" |GND
|GND
| colspan="1" rowspan="1" |GND
|GND
|}
|}
[[파일:WS2812_회로.png|center|class=coders100]]
[[File:WS2812 회로.png|center|class=coders100]]


== '''라이브러리''' ==
== '''Library''' ==


* Adafruit NeoPixel
* Adafruit NeoPixel ([[Arduino Libraries]])
 
[[아두이노 라이브러리]]


== '''예제 코드''' ==
== '''예제 코드''' ==
69번째 줄: 64번째 줄:
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoPixel.h>


//7번핀 사용
// Using pin number 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
//neopixel을 제어하기 위한 neo 생성
// Create a NeoPixel object for control
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
void setup() {
     //neopixel 시작
     // Start NeoPixel
     neo.begin();
     neo.begin();
     //neopixel 밝기 설정
     // Set NeoPixel brightness
     neo.setBrightness(bright);
     neo.setBrightness(bright);
     //neopixel 초기화
     // Initialize NeoPixel
     neo.clear();
     neo.clear();
     //neopixel 적용
     // Apply NeoPixel settings
     //.show()를 사용하기 전까진 내부적으로만 설정이 적용되었다 생각하면 됩니다.
     // Settings are applied internally until .show() is executed.
     //.show()가 실행되면 led에 내부적으로 적용된 명령들이 실행됩니다.
     // When .show() runs, the commands applied internally are executed on the LEDs.
     neo.show();
     neo.show();
}
}
94번째 줄: 89번째 줄:
void loop()
void loop()
{
{
     //led 흰색 점등
     // Turn LEDs white
     for (int i = 0; i < 15; i++)
     for (int i = 0; i < 15; i++)
     {
     {
         neo.setPixelColor(i,255,255,255);
         neo.setPixelColor(i, 255, 255, 255);
     }
     }
     neo.show();
     neo.show();
     delay(500);
     delay(500);


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


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


     //led 청색 점등
     // Turn LEDs blue
     for (int i = 0; i < 15; i++)
     for (int i = 0; i < 15; i++)
     {
     {
         neo.setPixelColor(i,0,0,255);
         neo.setPixelColor(i, 0, 0, 255);
     }
     }
     neo.show();
     neo.show();
     delay(500);
     delay(500);
}
}
</syntaxhighlight>
</syntaxhighlight>


=== 실행결과 ===
=== Execution Result ===
[[파일:Ws2812_시연.png|center|class=coders100]]
[[File:Ws2812 시연.png|center|class=coders100]]
 
== '''구매 링크''' ==
[https://smartstore.naver.com/gongzipsa/products/7401376660 공집사몰]

2024년 3월 23일 (토) 16:43 기준 최신판

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 terminal of a NeoPixel to the IN terminal of the next allows for controlling multiple NeoPixels with just one pin on the board.

Specifications

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

Required Hardware

  • NeoPixel
  • Arduino UNO
  • UNO cable
  • M-M cable(6ea)
  • F-M cable(3ea)

Connection (M-M and F-M cables were soldered for connection to the NeoPixel)

  • NeoPixel to Arduino Connection
NeoPixel Arduino
IN D7
VCC 5V
GND GND
  • Connection between the 1st and 2nd NeoPixel (apply the same method to add more NeoPixels):
1st NeoPixel 2nd NeoPixel
OUT IN
VCC VCC
GND GND

Library

예제 코드

#include <Adafruit_NeoPixel.h>

// Using pin number 7
#define PIN        7
// Number of pixels
#define NUMPIXELS 15
// Brightness level
#define bright 255
#define dly 10000
// Create a NeoPixel object for control
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
    // Start NeoPixel
    neo.begin();
    // Set NeoPixel brightness
    neo.setBrightness(bright);
    // Initialize NeoPixel
    neo.clear();
    // Apply NeoPixel settings
    // Settings are applied internally until .show() is executed.
    // When .show() runs, the commands applied internally are executed on the LEDs.
    neo.show();
}

void loop()
{
    // Turn LEDs white
    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);
}

Execution Result