“(SKU:ELB050083)WS2812串行5050全彩LED模块3*3点阵”的版本间的差异

来自YwRobot Studio Wiki
跳转至: 导航搜索
更多
样例代码
 
第31行: 第31行:
 
===样例代码===
 
===样例代码===
 
<pre style="color:blue">
 
<pre style="color:blue">
 +
#include <Adafruit_NeoPixel.h>
 +
 +
#define PIN 6
 +
#define BRIGHTNESS 50
 +
 +
Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);
 +
 +
void setup() {
 +
  strip.setBrightness(BRIGHTNESS);
 +
  strip.begin();
 +
  strip.show();
 +
}
 +
 +
void loop() {
 +
  colorWipe(strip.Color(150, 0, 0), 50); // Red
 +
  colorWipe(strip.Color(0, 150, 0), 50); // Green
 +
  colorWipe(strip.Color(0, 0, 150), 50); // Blue
 +
  colorWipe(strip.Color(150, 150, 150), 50); // BlueWite
 +
  rainbowCycle(1);
 +
 +
}
 +
 +
void colorWipe(uint32_t c, uint8_t wait) {
 +
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
 +
    strip.setPixelColor(i, c);
 +
    strip.show();
 +
    delay(wait);
 +
  }
 +
}
 +
 +
void rainbow(uint8_t wait) {
 +
  uint16_t i, j;
 +
  for (j = 0; j < 256; j++) {
 +
    for (i = 0; i < strip.numPixels(); i++) {
 +
      strip.setPixelColor(i, Wheel((i + j) & 255 ));
 +
    }
 +
    strip.show();
 +
    delay(wait);
 +
  }
 +
}
 +
 +
void rainbowCycle(uint8_t wait) {
 +
  uint16_t i, j;
 +
  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
 +
    for (i = 0; i < strip.numPixels(); i++) {
 +
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
 +
    }
 +
    strip.show();
 +
    delay(wait);
 +
  }
 +
}
 +
 +
uint32_t Wheel(byte WheelPos) {
 +
  if (WheelPos < 85) {
 +
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
 +
  } else if (WheelPos < 170) {
 +
    WheelPos -= 85;
 +
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
 +
  } else {
 +
    WheelPos -= 170;
 +
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
 +
  }
 +
}
  
 
</pre>
 
</pre>

2017年1月14日 (六) 16:52的最新版本

WS2812串行5050全彩LED模块3*3点阵


产品参数

  • 型号:RainBow LED C3x3
  • 尺寸:28*27mm
  • 芯片:WS2811(内置于LED)
  • LED:5050封装RGB全彩高亮*9
  • 电压:5V
  • 端口:数字
  • 平台:Arduino 单片机


产品特性

  • 5050高亮LED,内置控制芯片,仅需1个IO口即可控制多个LED
  • 芯片内置整形电路,信号畸变不会累计,稳定显示
  • 三基色256级亮度调剂,16万色真彩显示效果,扫描频率不低于400Hz/S
  • 串行连级接口,能通过一根信号线完成数据的接收与解码
  • 刷新速率30帧/秒时,低速连级模式连级数不小于512点
  • 数据收发速度最高可达800Kbps
  • 高亮LED,光色亮度一致性高
  • 两端有连级接口,可以直接插接


使用教程

WS2812串行5050全彩LED模块3*3点阵LINE.jpg

样例代码

#include <Adafruit_NeoPixel.h>

#define PIN 6
#define BRIGHTNESS 50

Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show();
}

void loop() {
  colorWipe(strip.Color(150, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 150, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 150), 50); // Blue
  colorWipe(strip.Color(150, 150, 150), 50); // BlueWite
  rainbowCycle(1);
 
}

void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;
  for (j = 0; j < 256; j++) {
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i + j) & 255 ));
    }
    strip.show();
    delay(wait);
  }
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;
  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

uint32_t Wheel(byte WheelPos) {
  if (WheelPos < 85) {
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
    WheelPos -= 170;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

更多

[YWRobot产品资料下载]
库文件下载

购买 YWRobot商城购买链接