Skip to content

Instantly share code, notes, and snippets.

@mathisonian
Created December 15, 2014 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathisonian/cbb9af2403f40e8b6945 to your computer and use it in GitHub Desktop.
Save mathisonian/cbb9af2403f40e8b6945 to your computer and use it in GitHub Desktop.
arduino
int ledStripRanges[19][2][2] = {
{
{900, 1018}, {600, 715}
},{
{1018, 1135}, {715, 828}
},{
{1135, 1200}, {828, 900}
},{
{538, 600}, {1738, 1800}
},{
{300, 420}, {420, 538}
},{
{0, 89}, {2100, 2190}
},{
{89, 179}, {2190, 2280}
},{
{179, 237}, {2280, 2337}
},{
{237, 300}, {2337, 2400}
},{
{1500, 1560}, {1560, 1620}
},{
{1620, 1680}, {1680, 1738}
},{
{1800, 1860}, {1860, 1920}
},{
{1920, 1980}, {1980, 2038}
},{
{1200, 1259}, {0, 0}
},{
{1259, 1319}, {1320, 1400}
},{
{2400, 2600}, {1400, 1500}
},{
{2600, 2900}, {0, 0}
},{
{0, 0}, {0, 0}
},{
{2038, 2100}, {0, 0}
}
};
int colors[19][2] = {
{0xE20005, 0xE20005},
{0xE20005, 0xE20005},
{0xF22306, 0xF22306},
{0xFC3607, 0xFC3607},
{0xFD6808, 0xFD6808},
{0xFD7A08, 0xFD7A08},
{0xF7A608, 0xF7A608},
{0xB0DB08, 0xB0DB08},
{0x8FB705, 0x8FB705},
{0x17B42F, 0x17B42F},
{0x17B42F, 0x17B42F},
{0x15A424, 0x15A424},
{0x0F712C, 0x0F712C},
{0x1397E1, 0x1397E1},
{0x1088CE, 0x1088CE},
{0x0E75C9, 0x0E75C9},
{0x0A59A5, 0x0A59A5},
{0x043178, 0x043178},
{0x043178, 0x043178}
};
/* OctoWS2811 Rainbow.ino - Rainbow Shifting Test
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Required Connections
--------------------
pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.
pin 1 - Output indicating CPU usage, monitor with an oscilloscope,
logic analyzer or even an LED (brighter = CPU busier)
*/
#include <OctoWS2811.h>
const int ledsPerStrip = 300;
DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];
const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT);
// digitalWrite(1, HIGH);
// for (int i=0; i<180; i++) {
// int hue = i * 2;
// int saturation = 100;
// int lightness = 50;
// pre-compute the 180 rainbow colors
// rainbowColors[i] = makeColor(hue, saturation, lightness);
// }
// digitalWrite(1, LOW);
leds.begin();
randomSeed(analogRead(0));
}
int count = 0;
int leftHeight = 19, rightHeight = 19;
void loop() {
// leds.setPixel(count, 0xFFFFFF);
if (Serial.available() > 0) {
// read the incoming byte:
leftHeight = Serial.parseInt();
rightHeight = Serial.parseInt();
// say what you got:
Serial.println("I received: ");
Serial.println(incomingByte1);
Serial.println(incomingByte2);
paint(leftHeight , rightHeight );
}
// count++;
// if (count > 100) {
// count = 0;
// }
}
// phaseShift is the shift between each row. phaseShift=0
// causes all rows to show the same colors moving together.
// phaseShift=180 causes each row to be the opposite colors
// as the previous.
//
// cycleTime is the number of milliseconds to shift through
// the entire 360 degrees of the color wheel:
// Red -> Orange -> Yellow -> Green -> Blue -> Violet -> Red
//
void paint(int highNumX, int highNumY)
{
// Serial.println(highNum);
int count = 0;
int x, y;
int highNums[2] = { highNumX, highNumY };
digitalWrite(1, HIGH);
for(y=0; y<2; y++) {
for(x=0; x < highNums[y]; x++) {
int *range = ledStripRanges[x][y];
if(range[0] == 0 && range[1] == 0) {
continue;
}
for(int i=range[0]; i<range[1]; i++) {
leds.setPixel(i, colors[18-x][y]);
}
}
}
leds.show();
digitalWrite(1, LOW);
// for(x=0; x < highNum; x++) {
// digitalWrite(1, HIGH);
// for(y=0; y<2; y++) {
// int *range = ledStripRanges[x][y];
// if(range[0] == 0 && range[1] == 0) {
// continue;
// }
// for(int i=range[0]; i<range[1]; i++) {
// leds.setPixel(i, colors[18-x][y]);
// }
// count++;
// }
// leds.show();
// digitalWrite(1, LOW);
// delayMicroseconds(10000);
// }
// delayMicroseconds(500000);
// for(x=highNum-1; x >= 0; x--) {
// digitalWrite(1, HIGH);
// for(y=0; y<2; y++) {
// int *range = ledStripRanges[x][y];
// if(range[0] == 0 && range[1] == 0) {
// continue;
// }
// for(int i=range[0]; i<range[1]; i++) {
// leds.setPixel(i, 0);
// }
// }
// leds.show();
// digitalWrite(1, LOW);
//// delayMicroseconds(30000);
// }
// delayMicroseconds(500000);
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment