“(SKU:ELB040055)16位环形WS2812串行5050全彩LED扩展模块”的版本间的差异
来自YwRobot Studio Wiki
YWrobot WM(讨论 | 贡献) |
(→样例代码) |
||
第32行: | 第32行: | ||
===样例代码=== | ===样例代码=== | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
+ | #include <Adafruit_NeoPixel.h> | ||
+ | |||
+ | #define PIN 6 | ||
+ | #define BRIGHTNESS 50 | ||
+ | |||
+ | Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, 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月13日 (五) 13:50的版本
产品参数
- 型号:RainBow LED R1
- 尺寸:61mm 直径
- 芯片:WS2811(内置于LED)
- LED:5050封装RGB全彩高亮*16
- 电压: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(16, 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产品资料下载]