MCookie-LED Matrix是彩色LED灯阵,共有6颗灯,每颗灯内置IC控制芯片,单总线控制,只需要一个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);
}