Neopixel Ring 24-LED(WS2812)

아두위키 : Arduwiki
ArduWiki (토론 | 기여)님의 2024년 3월 24일 (일) 18:09 판 (Created page with "{{#seo:|title=아두위키 : 아두이노 네오픽셀 가이드|title_mode=append|keywords=아두이노, 정보과학, 메이커학습, 수행평가, 네오픽셀, 아두이노 작품, 캡스톤작품, 아두이노 예제코드|description=아두이노로 네오픽셀을 제어하는 방법(기본정보, 회로, 예제 코드)을 소개합니다. 정보과학과 메이커수업에 활용가능합니다.}} center|class=coders100...")
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

Neopixel is an LED product from Adafruit that has a WS281x chip built-in.

It comes in various shapes like single, circular, and linear, making it convenient for different applications, with the advantage of easy wiring.

It is commonly used with microcontrollers like Arduino.

Specifications

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

Example Hardware

  • Arduino Board
  • 24-bit Neopixel

Connection

This component does not come with pre-attached wires, so you need to solder jumper wires before proceeding.

Arduino neo pixel
5V 5V
GND GND
D7 DI

Library

Adafruit Neopixel library is used.

Please refer to the Arduino library documentation for how to use the library.

Example Code

This example sequentially lights up 7 colors.

#include <Adafruit_NeoPixel.h>

#define PIN 7
#define NUMPIXELS 24
#define bright 255
#define dly 50
Adafruit_NeoPixel neo(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  neo.begin();
  neo.setBrightness(bright);
  neo.clear();
  neo.show();
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 255, 255, 255);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 255, 0, 0);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 0, 255, 0);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 0, 0, 255);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 255, 255, 0);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 0, 255, 255);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 255, 0, 255);
    neo.show();
    delay(dly);
  }
  for (int i = 0; i < NUMPIXELS; i++) {
    neo.setPixelColor(i, 0, 0, 0);
  }
  neo.show();
}

void loop() {
}

Execution Result

Please check the operational video from the link.