mCookie-LED Matrix模块集成了6个WS2812灯珠,每个灯珠内置IC控制芯片,6个灯珠采用单总线控制,可用一个I/O口控制每个灯珠的发光状态。可作为全彩模组提供光源。
#include <Adafruit_NeoPixel.h>
#define PIN A0 //led灯控制引脚
#define PIN_NUM 6 //允许接的led灯的个数
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIN_NUM, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
}
void loop() {
strip.setPixelColor(0, strip.Color(255, 0, 0));//红
strip.show();
delay(1000);
strip.setPixelColor(1, strip.Color(0, 255, 0));//绿
strip.show();
delay(1000);
strip.setPixelColor(2, strip.Color(0, 0, 255));//蓝
strip.show();
delay(1000);
strip.setPixelColor(3, strip.Color(255, 255, 0));
strip.show();
delay(1000);
strip.setPixelColor(4, strip.Color(0, 255, 255));
strip.show();
delay(1000);
strip.setPixelColor(5, strip.Color(255, 0, 255));
strip.show();
delay(1000);
}