Snippets
Created by
Jason Matusiak
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #include <FastLED.h>
#define LED_PIN 6
#define NUM_LEDS 5
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
CRGB colorIndex[5];
int inPin0 = 3; // input0
int inPin1 = 4; // input1
int inPin2 = 5; // input2
int val = 0; // variable to store the read value
int numColors = 0;
int k = 0;
void setup() {
pinMode(inPin0, INPUT_PULLUP); // sets the digital pin 3 as input
pinMode(inPin1, INPUT_PULLUP); // sets the digital pin 4 as input
pinMode(inPin2, INPUT_PULLUP); // sets the digital pin 5 as input
DDRD = B11000001; // sets Arduino pins to output and input
val = (PIND >> 3) & 0x7;
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
//currentBlending = NOBLEND;
if(val == 0)
{
//test sequence
numColors = 3;
colorIndex[0] = CRGB::Red;
colorIndex[1] = CRGB::Green;
colorIndex[2] = CRGB::Blue;
}
else if (val == 1)
{
//Halloween
numColors = 2;
colorIndex[0] = CRGB::Orange;
colorIndex[1] = CRGB::Purple;
}
else if (val == 2)
{
//Autumn
numColors = 5;
colorIndex[0] = CRGB::Red;
colorIndex[1] = CRGB::Yellow;
colorIndex[2] = CRGB::Green;
colorIndex[3] = CRGB::Orange;
colorIndex[4] = CRGB::Purple;
}
else if (val == 3)
{
//Christmas
numColors = 2;
colorIndex[0] = CRGB::Red;
colorIndex[1] = CRGB::Green;
}
else if (val == 4)
{
//Patriotic
numColors = 3;
colorIndex[0] = CRGB::Blue;
colorIndex[1] = CRGB::Gray;
colorIndex[2] = CRGB::Red;
}
else if (val == 5)
{
//Easter
numColors = 4;
colorIndex[0] = CRGB::Pink;
colorIndex[1] = CRGB::Gray;
colorIndex[2] = CRGB::Purple;
colorIndex[3] = CRGB::Yellow;
}
}
void loop()
{
if(val == 0)
{
for(int k = 0; k < numColors; k++)
{
for(int i = 0; i < NUM_LEDS; i++)
{
leds[i] = colorIndex[(i+k)%numColors];
}
FastLED.show();
FastLED.delay(3000);
}
}
else
{
for(int j = 0; j <256; j++)
{
for(int i = 0; i < NUM_LEDS; i++)
{
leds[i] = blend( CRGB::Black, colorIndex[(i+k)%numColors], j);
FastLED.show();
FastLED.delay(1);
}
}
FastLED.delay(300000);
for(int j = 255; j >=0; j--)
{
for(int i = 0; i < NUM_LEDS; i++)
{
leds[i] = blend( CRGB::Black, colorIndex[(i+k)%numColors], j);
FastLED.show();
FastLED.delay(1);
}
}
//FastLED.delay(300000);
k++;
if (k == numColors)
{
k = 0;
}
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.