From 7285f19643d57578ffe19b3ed35c027b27d9d997 Mon Sep 17 00:00:00 2001 From: OroArmor Date: Tue, 4 Dec 2018 19:04:21 -0800 Subject: [PATCH 1/5] First upload Uploading file with original code along with new "swirl" function (swirl in beta) --- NeoPixel.ino | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 NeoPixel.ino diff --git a/NeoPixel.ino b/NeoPixel.ino new file mode 100644 index 0000000..7ea09ad --- /dev/null +++ b/NeoPixel.ino @@ -0,0 +1,102 @@ +#include + #define NUM_LEDS 144 + #define DATA_PIN 6 + +CRGB leds[NUM_LEDS]; + +void setup() +{ + // put your setup code here, to run once: + FastLED.addLeds(leds, NUM_LEDS); + Serial.begin(9600); +} + +void loop() +{ + // put your main code here, to run repeatedly: +// sweep(255,0,0,30); +// sweep(0,0,0,30); +// sweep(0,255,0,30); +// sweep(0,0,0,30); +// sweep(0,0,255,30); +// sweep(0,0,0,30); +// sweep(255,255,255,30); +// sweep(0,0,0,30); + + CRGB swirlColors[2]= {CRGB(0,0,0), CRGB(0,0,255)}; + + swirl(swirlColors,30, 6); + +} + + +void swirl( CRGB colors[], int d, int repeat){ + +// for(int j = 0; j < 144; j++){ //do one complete rotation +// for(int i = 0; i< NUM_LEDS; i +=NUM_LEDS/sizeof(colors)){ // go through each color stepping a certain amount +// +// for(int l = 0; l < sizeof(colors); l++){ // go through each color again... +// for(int k = 0; k < NUM_LEDS/sizeof(colors); k++){ // and for some reason again +// leds[(i+j+k+l*sizeof(colors))%144 ] = colors[l]; // MaTH yAy! +// } +// } +// } +// FastLED.show(); +// delay(d); +// } + + int len = sizeof(colors); + for(int i = 0; i < NUM_LEDS; i++){ // one rotation + for(int j = 0; j < NUM_LEDS; j+= NUM_LEDS/(len*repeat)){ // len = sizeof(colors) this loop jumps to the start of each new color with the repeat amount + for(int k = 0; k < NUM_LEDS/(len*repeat) ; k++){ // display each led with correct color + leds[(i+j+k)%NUM_LEDS] = colors[NUM_LEDS/j]; + } + } + FastLED.show(); + delay(d); + } +} + + + +void sweep(byte red, byte green, byte blue, int d) +{ + for(int dot = 0; dot < NUM_LEDS; dot++) + { + leds[dot] = CRGB( red, green, blue); // set this pixel to color + FastLED.show(); + //leds[dot] = CRGB::Black; // clear this led for the next time around the loop + delay(d); + } +} +/* + +//Example 1: set color from red, green, and blue components individually + // The three color channel values can be referred to as "red", "green", and "blue"... + leds[i].red = 50; + leds[i].green = 100; + leds[i].blue = 150; + + // ...or, using the shorter synonyms "r", "g", and "b"... + leds[i].r = 50; + leds[i].g = 100; + leds[i].b = 150; + + // ...or as members of a three-element array: + leds[i][0] = 50; // red + leds[i][1] = 100; // green + leds[i][2] = 150; // blue + +//Example 2: set color from red, green, and blue components all at once + leds[i] = CRGB( 50, 100, 150); + +// Example 3: set color via 'hex color code' (0xRRGGBB) + leds[i] = 0xFF007F; + +// Example 4: set color via any named HTML web color + leds[i] = CRGB::HotPink; + +// Example 5: set color via setRGB + leds[i].setRGB( 50, 100, 150); + +*/ From 53f9ad8564d64287b7aeb8d4c21fa016b80e1d31 Mon Sep 17 00:00:00 2001 From: OroArmor Date: Wed, 5 Dec 2018 10:03:03 -0800 Subject: [PATCH 2/5] some bug fixes and code format. still needs testing --- NeoPixel.ino | 88 +++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/NeoPixel.ino b/NeoPixel.ino index 7ea09ad..210b80d 100644 --- a/NeoPixel.ino +++ b/NeoPixel.ino @@ -1,102 +1,86 @@ #include - #define NUM_LEDS 144 - #define DATA_PIN 6 +#define NUM_LEDS 144 +#define DATA_PIN 6 CRGB leds[NUM_LEDS]; void setup() { - // put your setup code here, to run once: FastLED.addLeds(leds, NUM_LEDS); - Serial.begin(9600); } void loop() { - // put your main code here, to run repeatedly: -// sweep(255,0,0,30); -// sweep(0,0,0,30); -// sweep(0,255,0,30); -// sweep(0,0,0,30); -// sweep(0,0,255,30); -// sweep(0,0,0,30); -// sweep(255,255,255,30); -// sweep(0,0,0,30); - - CRGB swirlColors[2]= {CRGB(0,0,0), CRGB(0,0,255)}; - - swirl(swirlColors,30, 6); - -} + // sweep(255,0,0,30); + // sweep(0,0,0,30); + // sweep(0,255,0,30); + // sweep(0,0,0,30); + // sweep(0,0,255,30); + // sweep(0,0,0,30); + // sweep(255,255,255,30); + // sweep(0,0,0,30); + + CRGB swirlColors[2] = {CRGB(0, 0, 0), CRGB(0, 0, 255)}; + swirl(swirlColors, 30, 6); -void swirl( CRGB colors[], int d, int repeat){ +} -// for(int j = 0; j < 144; j++){ //do one complete rotation -// for(int i = 0; i< NUM_LEDS; i +=NUM_LEDS/sizeof(colors)){ // go through each color stepping a certain amount -// -// for(int l = 0; l < sizeof(colors); l++){ // go through each color again... -// for(int k = 0; k < NUM_LEDS/sizeof(colors); k++){ // and for some reason again -// leds[(i+j+k+l*sizeof(colors))%144 ] = colors[l]; // MaTH yAy! -// } -// } -// } -// FastLED.show(); -// delay(d); -// } +void swirl( CRGB colors[], int d, int repeat) { // colors to display, delay between movement, number of times each color shows up. try to make colors * repeat = 144. int len = sizeof(colors); - for(int i = 0; i < NUM_LEDS; i++){ // one rotation - for(int j = 0; j < NUM_LEDS; j+= NUM_LEDS/(len*repeat)){ // len = sizeof(colors) this loop jumps to the start of each new color with the repeat amount - for(int k = 0; k < NUM_LEDS/(len*repeat) ; k++){ // display each led with correct color - leds[(i+j+k)%NUM_LEDS] = colors[NUM_LEDS/j]; + for (int i = 0; i < NUM_LEDS; i++) { // one rotation + int currentColor = 0; + for (int j = 0; j < NUM_LEDS; j += NUM_LEDS / (len * repeat)) { //this loop jumps to the start of each new color segment by that length + for (int k = 0; k < NUM_LEDS / (len * repeat) ; k++) { // display each led with correct color + leds[(i + j + k) % NUM_LEDS] = colors[currentColor%len]; } } FastLED.show(); + currentColor++; delay(d); - } + } } void sweep(byte red, byte green, byte blue, int d) { - for(int dot = 0; dot < NUM_LEDS; dot++) - { - leds[dot] = CRGB( red, green, blue); // set this pixel to color - FastLED.show(); - //leds[dot] = CRGB::Black; // clear this led for the next time around the loop - delay(d); - } + for (int dot = 0; dot < NUM_LEDS; dot++) + { + leds[dot] = CRGB( red, green, blue); // set this pixel to color + FastLED.show(); + delay(d); + } } /* -//Example 1: set color from red, green, and blue components individually + //Example 1: set color from red, green, and blue components individually // The three color channel values can be referred to as "red", "green", and "blue"... leds[i].red = 50; leds[i].green = 100; leds[i].blue = 150; - + // ...or, using the shorter synonyms "r", "g", and "b"... leds[i].r = 50; leds[i].g = 100; leds[i].b = 150; - + // ...or as members of a three-element array: leds[i][0] = 50; // red leds[i][1] = 100; // green leds[i][2] = 150; // blue -//Example 2: set color from red, green, and blue components all at once + //Example 2: set color from red, green, and blue components all at once leds[i] = CRGB( 50, 100, 150); - -// Example 3: set color via 'hex color code' (0xRRGGBB) + + // Example 3: set color via 'hex color code' (0xRRGGBB) leds[i] = 0xFF007F; -// Example 4: set color via any named HTML web color + // Example 4: set color via any named HTML web color leds[i] = CRGB::HotPink; -// Example 5: set color via setRGB + // Example 5: set color via setRGB leds[i].setRGB( 50, 100, 150); */ From 08cba9cbded3a5f391512aacd8a337871e525083 Mon Sep 17 00:00:00 2001 From: OroArmor Date: Wed, 5 Dec 2018 10:05:08 -0800 Subject: [PATCH 3/5] Rename NeoPixel.ino to Swirl.ino --- NeoPixel.ino => Swirl.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename NeoPixel.ino => Swirl.ino (100%) diff --git a/NeoPixel.ino b/Swirl.ino similarity index 100% rename from NeoPixel.ino rename to Swirl.ino From 732552cea2443c83e5f41daf1988f211dd7bfb88 Mon Sep 17 00:00:00 2001 From: OroArmor Date: Wed, 5 Dec 2018 10:06:12 -0800 Subject: [PATCH 4/5] Create NeoPixel.ino --- NeoPixel.ino | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 NeoPixel.ino diff --git a/NeoPixel.ino b/NeoPixel.ino new file mode 100644 index 0000000..fccaeb7 --- /dev/null +++ b/NeoPixel.ino @@ -0,0 +1,56 @@ +#include +#define NUM_LEDS 144 +#define DATA_PIN 6 + +CRGB leds[NUM_LEDS]; + +void setup() +{ + FastLED.addLeds(leds, NUM_LEDS); +} + +void loop() +{ + sweep(255,0,0,30); + sweep(0,0,0,30); + sweep(0,255,0,30); + sweep(0,0,0,30); + sweep(0,0,255,30); + sweep(0,0,0,30); + sweep(255,255,255,30); + sweep(0,0,0,30); + +} + +void sweep(byte red, byte green, byte blue, int d) +{ + for (int dot = 0; dot < NUM_LEDS; dot++) + { + leds[dot] = CRGB( red, green, blue); // set this pixel to color + FastLED.show(); + delay(d); + } +} +/* + //Example 1: set color from red, green, and blue components individually + // The three color channel values can be referred to as "red", "green", and "blue"... + leds[i].red = 50; + leds[i].green = 100; + leds[i].blue = 150; + // ...or, using the shorter synonyms "r", "g", and "b"... + leds[i].r = 50; + leds[i].g = 100; + leds[i].b = 150; + // ...or as members of a three-element array: + leds[i][0] = 50; // red + leds[i][1] = 100; // green + leds[i][2] = 150; // blue + //Example 2: set color from red, green, and blue components all at once + leds[i] = CRGB( 50, 100, 150); + // Example 3: set color via 'hex color code' (0xRRGGBB) + leds[i] = 0xFF007F; + // Example 4: set color via any named HTML web color + leds[i] = CRGB::HotPink; + // Example 5: set color via setRGB + leds[i].setRGB( 50, 100, 150); +*/ From e88ca90a02828728ff1a31c098dd28185742c211 Mon Sep 17 00:00:00 2001 From: OroArmor Date: Wed, 5 Dec 2018 10:06:47 -0800 Subject: [PATCH 5/5] Delete Swirl.ino --- Swirl.ino | 86 ------------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 Swirl.ino diff --git a/Swirl.ino b/Swirl.ino deleted file mode 100644 index 210b80d..0000000 --- a/Swirl.ino +++ /dev/null @@ -1,86 +0,0 @@ -#include -#define NUM_LEDS 144 -#define DATA_PIN 6 - -CRGB leds[NUM_LEDS]; - -void setup() -{ - FastLED.addLeds(leds, NUM_LEDS); -} - -void loop() -{ - // sweep(255,0,0,30); - // sweep(0,0,0,30); - // sweep(0,255,0,30); - // sweep(0,0,0,30); - // sweep(0,0,255,30); - // sweep(0,0,0,30); - // sweep(255,255,255,30); - // sweep(0,0,0,30); - - CRGB swirlColors[2] = {CRGB(0, 0, 0), CRGB(0, 0, 255)}; - - swirl(swirlColors, 30, 6); - -} - - -void swirl( CRGB colors[], int d, int repeat) { // colors to display, delay between movement, number of times each color shows up. try to make colors * repeat = 144. - int len = sizeof(colors); - for (int i = 0; i < NUM_LEDS; i++) { // one rotation - int currentColor = 0; - for (int j = 0; j < NUM_LEDS; j += NUM_LEDS / (len * repeat)) { //this loop jumps to the start of each new color segment by that length - for (int k = 0; k < NUM_LEDS / (len * repeat) ; k++) { // display each led with correct color - leds[(i + j + k) % NUM_LEDS] = colors[currentColor%len]; - } - } - FastLED.show(); - currentColor++; - delay(d); - } -} - - - -void sweep(byte red, byte green, byte blue, int d) -{ - for (int dot = 0; dot < NUM_LEDS; dot++) - { - leds[dot] = CRGB( red, green, blue); // set this pixel to color - FastLED.show(); - delay(d); - } -} -/* - - //Example 1: set color from red, green, and blue components individually - // The three color channel values can be referred to as "red", "green", and "blue"... - leds[i].red = 50; - leds[i].green = 100; - leds[i].blue = 150; - - // ...or, using the shorter synonyms "r", "g", and "b"... - leds[i].r = 50; - leds[i].g = 100; - leds[i].b = 150; - - // ...or as members of a three-element array: - leds[i][0] = 50; // red - leds[i][1] = 100; // green - leds[i][2] = 150; // blue - - //Example 2: set color from red, green, and blue components all at once - leds[i] = CRGB( 50, 100, 150); - - // Example 3: set color via 'hex color code' (0xRRGGBB) - leds[i] = 0xFF007F; - - // Example 4: set color via any named HTML web color - leds[i] = CRGB::HotPink; - - // Example 5: set color via setRGB - leds[i].setRGB( 50, 100, 150); - -*/