메이커 Maker

WS2812 아두이노 5050 RGB LED 모듈 12R

지구빵집 2018. 1. 11. 10:11
반응형




WS2812 아두이노 5050 RGB LED 모듈 12R


WS2812 기반 아두이노 RGB LED 모듈 / 작동 전압 : 5V / LED당 18mA 전류 소모 / 1-wire / -40도 ~ 85도 / 39 x 39 x 3.5mm


외관 이미지






구매 링크 : https://www.devicemart.co.kr/1327852/related/#    3,400원 


사용법 링크 - WS2812 color LED 사용하기  https://arsviator.blogspot.kr/2015/04/ws2812-color-led.html


구매참고 링크 - https://ko.aliexpress.com/item/RGB-LED-12-WS2812-WS2812B-5050-RGB-LED-I2C/32837547125.html


데이터북 참고 


WS2812.pdf



연결은 데이터 입력핀에 적당한 아두이노 핀을 연결한다.





샘플코드 1


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Example programs using the Adafruit Library
 
// Ex1) Lighting the pixels one after the other
 
#include <Adafruit_NeoPixel.h>
 
#define pinPix 12 // WS2812에 연결하는데 사용하는 pin 번호
#define numPix 16 // 링에 연결되어 있는 WS2812 LED 갯수
 
// Parameter 1 = 링에 연결되어 있는 WS2812 LED 갯수
// Parameter 2 = WS2812에 연결하는데 사용하는 pin 번호
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
 
Adafruit_NeoPixel myLeds = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800);
 
void setup() {
  myLeds.begin(); // Initialize the NeoPixel array in the Arduino's memory,
  myLeds.show(); // turn all pixels off, and upload to ring or string
}
 
void loop() {
  int pause = 100;
 
  for (int i=0; i<numPix; i++) { 
    myLeds.setPixelColor(i,255,255,255);
    myLeds.show();
    delay(pause);
  }
 
  for (int i=0; i<numPix; i++) {
    myLeds.setPixelColor(i,0,0,0);
    myLeds.show();
    delay(pause);
  }
}
cs



샘플코드 2


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Ex2) Lighting all the pixels simultaneosly
 
#include <Adafruit_NeoPixel.h> // Library for NeoPixels
 
#define pinPix 12 // Pin driving NeoPixel Ring or String
#define numPix 16 // Number of NeoPixels in the Ring or Strip
 
Adafruit_NeoPixel myLeds = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800);
 
void setup() {
  myLeds.begin(); // Initialize the NeoPixel array in the Arduino's memory,  
  myLeds.show(); // turn all pixels off, and upload to ring or string
}
 
void loop() {
  for (int i=0; i<numPix; i++) {
    myLeds.setPixelColor(i,255,255,255);
  }
  myLeds.show();
  delay(pause);
 
  for (int i=0; i<numPix; i++) {
    myLeds.setPixelColor(i,0,0,0);
  }
  myLeds.show();
  delay(pause);
}
 
cs






반응형