/* Animated LED cloud with multiple weather patterns Connect a strip of addressable LEDs to an arduino with GND to GND, LED power to Vin, and LED data to Pin 6 Tested on an Arduino Uno with Adafruit neopixels. Will work with other strips, but will require changes to the the "strip" settings below. With 30 LEDs, it can be powered over USB, or a good 2A external phone charging battery connected to the arduino. To build, place in a folder named "Cloud_Main", open "Cloud_Main.ino" with the Arduino IDE. In the Arduino IDE, select your matching board, and use the plugin manager to install the Adafruit_NeoPixel library. To construct a cloud, tape 2 wire coat hangers together, both upright with a right angle between them. Tape the Arduino up near the hooks, and arrange the LED strip to wind throughout the volume, facing outwards as much as possible. Then fill that volume with polyester fill (which goes in stuffed animals) to cover the LEDs. Clear tape can help keep the cloud together. Arrange the polyfill so that the hangers and LED strip are hidden. */ #include #define PIN 14 #define ledCount 60 Adafruit_NeoPixel strip = Adafruit_NeoPixel(ledCount, PIN, NEO_GRB + NEO_KHZ800); //first number controls the amount of pixels you have (add 4 so the drip falls off the edge) //Adafruit_NeoPixel stripOld = Adafruit_NeoPixel(ledCount, 7, NEO_GRB + NEO_KHZ800); //Adafruit_Neopixel stripNew = Adafruit_NeoPixel(ledCount, 8, NEO_GRB + NEO_KHZ800); int oldR[ledCount]; int oldG[ledCount]; int oldB[ledCount]; int newR[ledCount]; int newG[ledCount]; int newB[ledCount]; int nmax = 255; //---LED FX VARS int idex = 0; //-LED INDEX (0 to LED_COUNT-1 int ihue = 150; //-HUE (0-255) int ibright = 50; //-BRIGHTNESS (0-255) int isat = 240; //-SATURATION (0-255) int bouncedirection = 0; //-SWITCH FOR COLOR BOUNCE (0-1) float tcount = 0.0; //-INC VAR FOR SIN LOOPS int lcount = 0; //-ANOTHER COUNTING VAR int TOP_INDEX = ledCount/2; int BOTTOM_INDEX = 0; int thissat = 255; int EVENODD = ledCount%2; int tijd = 0; int sunnyBrightness = 200; int star1Loc = 6; // not used int star2Loc = 30; // not used int moonLoc = 2; // not used void setup() { Serial.begin(9600); // open the serial port at 9600 bps: strip.begin(); strip.show(); // Initialize all pixels to 'off' randomSeed(analogRead(0)); //EXTRA RANDOMNESS!!!!! } void loop() { boolean DemoMode = true; if(DemoMode){ long tijd = millis(); tijd /= 10000; switch (tijd % 15){ case 0: HexLights(); break; case 1: diamond(); break; case 2: pastel_propeller(); break; case 3: random_index(); break; case 4: random_blue(); break; case 5: blue_flower(); break; case 6: pink_sparkles(); break; case 7: blue_cycle(); //springt hard terug zou in reverse moeten } } else{ //set DemoMode false and test functions here! //blue_cycle(); //pink_sparkles(); //diamond(); //pastel_propeller(); // random_index(); // niet zo boeiend //blue_flower(); // random_blue(); // HexLights(); //ZeroLight(); } } //============================my voids=========================================================== void HexLights(){ int num_sections = 6; int zero_led = 6; for(int i = 0; i < ledCount; i++) { int Hue = (floor(((i-zero_led+ledCount)%ledCount)/(ledCount/num_sections))) * 360/num_sections; setHSV(i, Hue, 255, 255); } //Serial.println((i-zero_led+ledCount)%ledCount); strip.show(); //delay(10); }//void HexLights //================================================================================================== void blue_flower(){ int num_sections = 6; int zero_led = 6; for(int i = 0; i < ledCount; i++) { int baseColor = 180; int N10 = (ledCount/6); int N20 = (ledCount/3); int N30 = (ledCount/2); int N40 = (ledCount-N20); int N50 = (ledCount-N10); setHSV(i, baseColor, 255, 255); if(i == 0) baseColor = 220; if(i == N10) baseColor = 220; if(i == N20) baseColor = 220; if(i == N30) baseColor = 220; if(i == N40) baseColor = 220; if(i == N50) baseColor = 220; setHSV(i, baseColor, 255, 255); if(i == 0 + ledCount/9) baseColor = 0; if(i == N10 + ledCount/9) baseColor = 160; if(i == N20 + ledCount/9) baseColor = 160; if(i == N30 + ledCount/9) baseColor = 160; if(i == N40 + ledCount/9) baseColor = 160; if(i == N50 + ledCount/9) baseColor = 160; setHSV(i, baseColor, 100, 255); } strip.show(); //delay(10); }//void blue_flower //============================================================ void diamond(){ for(int i = 0; i< ledCount;i++){ newR[i] = random(0,150);//redish newG[i] = random(50,256); newB[i] = random(150,256); } for(int n = 0; n < 256; n++){ //update over time for(int i=0;i>8; unsigned int top = val; unsigned char rising = ((top-bottom) *(hue%60 ) ) / 60 + bottom; unsigned char falling = ((top-bottom) *(60-hue%60) ) / 60 + bottom; switch(H_accent) { case 0: r = top; g = rising; b = bottom; break; case 1: r = falling; g = top; b = bottom; break; case 2: r = bottom; g = top; b = rising; break; case 3: r = bottom; g = falling; b = top; break; case 4: r = rising; g = bottom; b = top; break; case 5: r = top; g = bottom; b = falling; break; } strip.setPixelColor(led, r, g, b); } void setAllHSV(unsigned int h, byte s, byte v) //Set all leds to one HSV { for (int i = 0; i< ledCount;i++) { setHSV(i, h, s, v); } } //---FIND ADJACENT INDEX CLOCKWISE int adjacent_cw(int i) { int r; if (i < ledCount - 1) {r = i + 1;} else {r = 0;} return r; } //---FIND ADJACENT INDEX COUNTER-CLOCKWISE int adjacent_ccw(int i) { int r; if (i > 0) {r = i - 1;} else {r = ledCount - 1;} return r; } //---FIND INDEX OF HORIZONAL OPPOSITE LED int horizontal_index(int i) { //-ONLY WORKS WITH INDEX < TOPINDEX if (i == BOTTOM_INDEX) {return BOTTOM_INDEX;} if (i == TOP_INDEX && EVENODD == 1) {return TOP_INDEX + 1;} if (i == TOP_INDEX && EVENODD == 0) {return TOP_INDEX;} return ledCount - i; }