_SKU_FIT0352__WS2812_RGB灯 - jimaobian/DFRobotWikiCn GitHub Wiki

WS2812 RGB灯 (SKU:FIT0352)

简介

这是一种内含芯片(WS2812)的LED灯条,用户可以单独控制每个LED,每米有60个RGB的LED,可以呈现出各种颜色。仅需要Arduino可以提供3.3V-5V的数字引脚驱动即可。

技术规格

每米包含60个灯珠 最大电流:1A(每米LED灯带)@5V(可以工作在3.3v-5V之间) 对于该条带,至少需要5V / 3A,因为它是3米长,如果电流不够,颜色可能不正确 芯片名称:WS2812 亮度等级:256 防水

连接图

示例代码


/*
 This code can be a good test code for your strip
 function: leds.setPixelColor(i,y) can be used to let number i of your led turn on with color of y
 and you can draw your idea easily with this function but never forget function: led.show()
*/

#include <Adafruit_NeoPixel.h>

#define PIN 6     //The signal pin connected with Arduino
#define LED_COUNT 180 // the amount of the leds of your strip

// Create an instance of the Adafruit_NeoPixel class called "leds".
// That'll be what we refer to from here on...
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
  leds.begin();  // Call this to start up the LED strip.
  clearLEDs();   // This function, defined below, turns all LEDs off...
  leds.show();   // ...but the LEDs don't actually update until you call this.
}

void loop()
{
    for (int i=0; i<LED_COUNT; i++)
  {
    rainbow(i);
    delay(50);  // Delay between rainbow slides
  }
}


// Sets all LEDs to off, but DOES NOT update the display;
// call leds.show() to actually turn them off after this.
void clearLEDs()
{
  for (int i=0; i<LED_COUNT; i++)
  {
    leds.setPixelColor(i, 0);
  }
}

// Prints a rainbow on the ENTIRE LED strip.
//  The rainbow begins at a specified position.
// ROY G BIV!
void rainbow(byte startPosition)
{
  // Need to scale our rainbow. We want a variety of colors, even if there
  // are just 10 or so pixels.
  int rainbowScale = 192 / LED_COUNT;

  // Next we setup each pixel with the right color
  for (int i=0; i<LED_COUNT; i++)
  {
    // There are 192 total colors we can get out of the rainbowOrder function.
    // It'll return a color between red->orange->green->...->violet for 0-191.
    leds.setPixelColor(i, rainbowOrder((rainbowScale * (i + startPosition)) % 192));
  }
  // Finally, actually turn the LEDs on:
  leds.show();
}

// Input a value 0 to 191 to get a color value.
// The colors are a transition red->yellow->green->aqua->blue->fuchsia->red...
//  Adapted from Wheel function in the Adafruit_NeoPixel library example sketch
uint32_t rainbowOrder(byte position)
{
  // 6 total zones of color change:
  if (position < 31)  // Red -> Yellow (Red = FF, blue = 0, green goes 00-FF)
  {
    return leds.Color(0xFF, position * 8, 0);
  }
  else if (position < 63)  // Yellow -> Green (Green = FF, blue = 0, red goes FF->00)
  {
    position -= 31;
    return leds.Color(0xFF - position * 8, 0xFF, 0);
  }
  else if (position < 95)  // Green->Aqua (Green = FF, red = 0, blue goes 00->FF)
  {
    position -= 63;
    return leds.Color(0, 0xFF, position * 8);
  }
  else if (position < 127)  // Aqua->Blue (Blue = FF, red = 0, green goes FF->00)
  {
    position -= 95;
    return leds.Color(0, 0xFF - position * 8, 0xFF);
  }
  else if (position < 159)  // Blue->Fuchsia (Blue = FF, green = 0, red goes 00->FF)
  {
    position -= 127;
    return leds.Color(position * 8, 0, 0xFF);
  }
  else  //160 <position< 191   Fuchsia->Red (Red = FF, green = 0, blue goes FF->00)
  {
    position -= 159;
    return leds.Color(0xFF, 0x00, 0xFF - position * 8);
  }
}

文件

Arduino Library for LED Strip RGB LED Strip Datasheet Arduino IDE (根据能够使用的Arduino版本来选择,不要盲目追求最新版本), 点击下载Arduino IDE

Mind+(基于Scratch3.0)图形化编程

1、下载及安装软件。下载地址:http://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装 2、切换到“上传模式”。 详细教程:Mind+基础wiki教程-上传模式编程流程 3、“扩展”中选择“主控板”中的“Arduino Uno”,“显示器”中加载“WS2812 RGB灯”。 详细教程:Mind+基础wiki教程-加载扩展库流程 4、进行编程,程序如下图: 5、菜单“连接设备”,“上传到设备”

结果

代码上传完成后,观察到灯带从第一颗LED到第七颗LED循环点亮,且呈现蓝色光。

常见问题

还没有客户对此产品有任何问题,欢迎通过qq或者论坛联系我们!

File:nextredirectltr.png购买 WS2812 LED灯(SKU:FIT0352)

⚠️ **GitHub.com Fallback** ⚠️