我需要在我的Arduino上为一个项目构建一个neopixel显示器,利用多个neopixel strip。我的第一步是让这些neopixel strip在电路上工作。在circuits.io中,它们只有一个可以串起来的单个。
我刚刚开始使用第一个neopixel,它工作得很好。现在,在再添加5套之后,第一套不起作用,但其余的则不行!
这是草图:https://circuits.io/circuits/5073229-v2g-display
这是我的代码(也在草图中):
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define NUMNUCLEARPIXELS 3
#define NUMWINDSOLARPIXELS 3
#define NUMSUBSTATIONPIXELS 3
#define NUMFACTORYPIXELS 3
#define NUMEVPIXELS 3
#define NUMHOMEPIXELS 3
Adafruit_NeoPixel nuclearpixels = Adafruit_NeoPixel(NUMNUCLEARPIXELS, 3 /*pin*/, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel windsolarpixels = Adafruit_NeoPixel(NUMWINDSOLARPIXELS, 5 /*pin*/, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel substationpixels = Adafruit_NeoPixel(NUMSUBSTATIONPIXELS, 6 /*pin*/, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel factorypixels = Adafruit_NeoPixel(NUMFACTORYPIXELS, 10 /*pin*/, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel evpixels = Adafruit_NeoPixel(NUMEVPIXELS, 11 /*pin*/, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel homepixels = Adafruit_NeoPixel(NUMHOMEPIXELS, 9 /*pin*/, NEO_GRB + NEO_KHZ800);
int delayval = 0; // delay for half a second
int windsolarbutton = 8;
int factorybutton = 2;
int evbutton = 4;
int homebutton = 7;
// the setup routine runs once when you press reset:
void setup() {
// initialize digital pins as input or output
pinMode(windsolarbutton, INPUT);
pinMode(factorybutton, INPUT);
pinMode(evbutton, INPUT);
pinMode(homebutton, INPUT);
nuclearpixels.begin(); // This initializes the NeoPixel library.
windsolarpixels.begin();
substationpixels.begin();
factorypixels.begin();
evpixels.begin();
homepixels.begin();
}
// the loop routine runs over and over again forever:
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMNUCLEARPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
nuclearpixels.setPixelColor(i, nuclearpixels.Color(0,150,0)); // Moderately bright green color.\
nuclearpixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMWINDSOLARPIXELS;i++){
windsolarpixels.setPixelColor(i, windsolarpixels.Color(0,150,0));
windsolarpixels.show();
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMSUBSTATIONPIXELS;i++){
substationpixels.setPixelColor(i, substationpixels.Color(0,150,0));
substationpixels.show();
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMFACTORYPIXELS;i++){
factorypixels.setPixelColor(i, factorypixels.Color(0,150,0));
factorypixels.show();
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMEVPIXELS;i++){
evpixels.setPixelColor(i, evpixels.Color(0,150,0));
evpixels.show();
delay(delayval); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMHOMEPIXELS;i++){
homepixels.setPixelColor(i, homepixels.Color(0,150,0));
homepixels.show();
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
谢谢,谢谢你的帮助!