|
|
@@ -37,36 +37,38 @@ void HSVtoRGB(float H, float S,float V,int &R, int &G, int &B){
|
|
|
|
|
|
|
|
|
#define PIN1 0
|
|
|
-#define PIN2 3
|
|
|
-#define PIN3 4
|
|
|
#define NUMPIXELS 25 // 24
|
|
|
#define CENTER 12.5
|
|
|
+int mode;
|
|
|
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;
|
|
|
+int PIN_COUNT = 1;
|
|
|
double hue = 0.0;
|
|
|
void setup() {
|
|
|
|
|
|
- pinMode(1, OUTPUT); //LED on Model A
|
|
|
+ pinMode(13, OUTPUT); //LED on Model A
|
|
|
+ pinMode(10, INPUT); //LED on Model A
|
|
|
+ digitalWrite(13, LOW); //LED on Model A
|
|
|
pinMode(PIN1, OUTPUT);
|
|
|
- pinMode(PIN2, OUTPUT);
|
|
|
- pinMode(PIN3, OUTPUT);
|
|
|
- for(int x=0;x<PIN_COUNT; x++) {
|
|
|
- pixels[x].begin();
|
|
|
- }
|
|
|
+ pixels[0].begin();
|
|
|
+ randomSeed(analogRead(10));
|
|
|
+ mode = random(1,4);
|
|
|
+ for(int i=0;i<=mode;i++) {
|
|
|
+ digitalWrite(13, LOW); //LED on Model A
|
|
|
+ delay(100);
|
|
|
+ digitalWrite(13, HIGH); //LED on Model A
|
|
|
+ delay(100);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 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 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 );
|
|
|
+ int hueOffset = (abs(CENTER-i)/(float)CENTER) * 50 * ( mode );
|
|
|
double h = (hue + hueOffset)/360.,y;
|
|
|
while(h>1) h-=1;
|
|
|
if(h<=0.5)
|
|
|
@@ -75,10 +77,10 @@ double hue = 0.0;
|
|
|
y = 1-pow(1-h,power)*fac;
|
|
|
|
|
|
HSVtoRGB(y*360, 100, 55,r,g,b);
|
|
|
- pixels[x].setPixelColor(i, pixels[x].Color(r,g,b)); // Moderately bright green color.
|
|
|
+ pixels[0].setPixelColor(i, pixels[0].Color(r,g,b)); // Moderately bright green color.
|
|
|
}
|
|
|
- pixels[x].show(); // This sends the updated pixel color to the hardware.
|
|
|
- }
|
|
|
+ pixels[0].show(); // This sends the updated pixel color to the hardware.
|
|
|
+
|
|
|
hue -= 0.4;
|
|
|
if(hue>=360) {
|
|
|
hue -= 360;
|
|
|
@@ -88,7 +90,7 @@ double hue = 0.0;
|
|
|
}
|
|
|
// digitalWrite(1, LOW); //LED on Model A
|
|
|
delay(15); // Delay for a period of time (in milliseconds).
|
|
|
- digitalWrite(1, HIGH); //LED on Model A
|
|
|
+ digitalWrite(13, LOW); //LED on Model A
|
|
|
}
|
|
|
|
|
|
|