|
|
@@ -36,46 +36,59 @@ void HSVtoRGB(float H, float S,float V,int &R, int &G, int &B){
|
|
|
|
|
|
|
|
|
|
|
|
-#define PIN 0
|
|
|
+#define PIN1 0
|
|
|
+#define PIN2 3
|
|
|
+#define PIN3 4
|
|
|
#define NUMPIXELS 25 // 24
|
|
|
#define CENTER 12.5
|
|
|
-Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
|
|
+Adafruit_NeoPixel pixels[] = {
|
|
|
+ Adafruit_NeoPixel(NUMPIXELS, PIN1, NEO_GRB + NEO_KHZ800),
|
|
|
+ Adafruit_NeoPixel(NUMPIXELS, PIN2, NEO_GRB + NEO_KHZ800),
|
|
|
+ Adafruit_NeoPixel(NUMPIXELS, PIN3, NEO_GRB + NEO_KHZ800)
|
|
|
+};
|
|
|
+int PIN_COUNT = 3;
|
|
|
double hue = 0.0;
|
|
|
- void setup() {
|
|
|
- pixels.begin();
|
|
|
+ void setup() {
|
|
|
+
|
|
|
pinMode(1, OUTPUT); //LED on Model A
|
|
|
- pinMode(PIN, OUTPUT); //LED on Model A
|
|
|
- digitalWrite(1, HIGH);
|
|
|
- delay(500);
|
|
|
- digitalWrite(1, LOW);
|
|
|
+ pinMode(PIN1, OUTPUT);
|
|
|
+ pinMode(PIN2, OUTPUT);
|
|
|
+ pinMode(PIN3, OUTPUT);
|
|
|
+ for(int x=0;x<PIN_COUNT; x++) {
|
|
|
+ pixels[x].begin();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// the loop routine runs over and over again forever:
|
|
|
void loop() {
|
|
|
static double power = 1.5;
|
|
|
static double fac = 0.5/pow(0.5,power);
|
|
|
- for(int i=0;i<NUMPIXELS;i++){
|
|
|
- int r,g,b;
|
|
|
- int hueOffset = (abs(CENTER-i)/(float)CENTER) * 150;
|
|
|
- double h = (hue + hueOffset)/360.,y;
|
|
|
- if(h>1) h -= (int)h;
|
|
|
- if(h<=0.5)
|
|
|
- y = pow(h,power)*fac;
|
|
|
- else
|
|
|
- y = 1-pow(1-h,power)*fac;
|
|
|
+ for(int x=0;x<PIN_COUNT; x++) {
|
|
|
+ for(int i=0;i<NUMPIXELS;i++){
|
|
|
+ int r,g,b;
|
|
|
+ int hueOffset = (abs(CENTER-i)/(float)CENTER) * 50 * ( x + 1 );
|
|
|
+ double h = (hue + hueOffset)/360.,y;
|
|
|
+ while(h>1) h-=1;
|
|
|
+ if(h<=0.5)
|
|
|
+ y = pow(h,power)*fac;
|
|
|
+ else
|
|
|
+ y = 1-pow(1-h,power)*fac;
|
|
|
|
|
|
- HSVtoRGB(y*360, 100, 15,r,g,b);
|
|
|
- pixels.setPixelColor(i, pixels.Color(r,g,b)); // Moderately bright green color.
|
|
|
+ HSVtoRGB(y*360, 100, 55,r,g,b);
|
|
|
+ pixels[x].setPixelColor(i, pixels[x].Color(r,g,b)); // Moderately bright green color.
|
|
|
+ }
|
|
|
+ pixels[x].show(); // This sends the updated pixel color to the hardware.
|
|
|
}
|
|
|
- hue -= 0.2;
|
|
|
+ hue -= 0.4;
|
|
|
if(hue>=360) {
|
|
|
hue -= 360;
|
|
|
}
|
|
|
if(hue<=0) {
|
|
|
hue = 360 + hue;
|
|
|
}
|
|
|
- pixels.show(); // This sends the updated pixel color to the hardware.
|
|
|
+ // digitalWrite(1, LOW); //LED on Model A
|
|
|
delay(15); // Delay for a period of time (in milliseconds).
|
|
|
+ digitalWrite(1, HIGH); //LED on Model A
|
|
|
}
|
|
|
|
|
|
|