“(SKU:ELB050084)WS2812串行5050全彩LED模块2*2点阵”的版本间的差异
来自YwRobot Studio Wiki
YWrobot WB1(讨论 | 贡献) (创建页面,内容为“WS2812串行5050全彩LED模块2*2点阵 ==产品参数== *型号:RainBow LED C2x2 *...”) |
(→样例代码) |
||
(未显示2个用户的2个中间版本) | |||
第26行: | 第26行: | ||
==使用教程== | ==使用教程== | ||
− | [[File:WS2812串行5050全彩LED模块2*2点阵LINE.jpg| | + | [[File:WS2812串行5050全彩LED模块2*2点阵LINE.jpg|800px|]] |
===样例代码=== | ===样例代码=== | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
+ | #include <Adafruit_NeoPixel.h> | ||
+ | |||
+ | #define PIN 6 | ||
+ | #define BRIGHTNESS 50 | ||
+ | |||
+ | Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, 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> | ||
第36行: | 第99行: | ||
[YWRobot产品资料下载] | [YWRobot产品资料下载] | ||
<br> | <br> | ||
− | + | 库文件下载 | |
+ | *[http://wiki.ywrobot.net/download/libraries/Adafruit_NeoPixel.rar Adafruit_NeoPixel] | ||
购买 [https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-11865958756.9.8TIkES&id=522747059511 YWRobot商城购买链接] | 购买 [https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-11865958756.9.8TIkES&id=522747059511 YWRobot商城购买链接] | ||
<br><br> | <br><br> |
2017年1月14日 (六) 16:12的最新版本
产品参数
- 型号:RainBow LED C2x2
- 尺寸:18*16mm
- 芯片:WS2811(内置于LED)
- LED:5050封装RGB全彩高亮*4
- 电压:5V
- 端口:数字
- 平台:Arduino 单片机
产品特性
- 5050高亮LED,内置控制芯片,仅需1个IO口即可控制多个LED
- 芯片内置整形电路,信号畸变不会累计,稳定显示
- 三基色256级亮度调剂,16万色真彩显示效果,扫描频率不低于400Hz/S
- 串行连级接口,能通过一根信号线完成数据的接收与解码
- 刷新速率30帧/秒时,低速连级模式连级数不小于512点
- 数据收发速度最高可达800Kbps
- 高亮LED,光色亮度一致性高
- 两端有连级接口,可以直接插接
使用教程
样例代码
#include <Adafruit_NeoPixel.h> #define PIN 6 #define BRIGHTNESS 50 Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, 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产品资料下载]
库文件下载