-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
2,801,422 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#include <FastLED.h> | ||
|
||
#define LED_PIN 1 | ||
#define COLOR_ORDER GRB | ||
#define CHIPSET WS2812 | ||
#define NUM_LEDS 150 | ||
|
||
#define BRIGHTNESS 200 | ||
#define FRAMES_PER_SECOND 60 | ||
|
||
bool gReverseDirection = false; | ||
|
||
CRGB leds[NUM_LEDS]; | ||
|
||
// Fire2012 with programmable Color Palette | ||
// | ||
// This code is the same fire simulation as the original "Fire2012", | ||
// but each heat cell's temperature is translated to color through a FastLED | ||
// programmable color palette, instead of through the "HeatColor(...)" function. | ||
// | ||
// Four different static color palettes are provided here, plus one dynamic one. | ||
// | ||
// The three static ones are: | ||
// 1. the FastLED built-in HeatColors_p -- this is the default, and it looks | ||
// pretty much exactly like the original Fire2012. | ||
// | ||
// To use any of the other palettes below, just "uncomment" the corresponding code. | ||
// | ||
// 2. a gradient from black to red to yellow to white, which is | ||
// visually similar to the HeatColors_p, and helps to illustrate | ||
// what the 'heat colors' palette is actually doing, | ||
// 3. a similar gradient, but in blue colors rather than red ones, | ||
// i.e. from black to blue to aqua to white, which results in | ||
// an "icy blue" fire effect, | ||
// 4. a simplified three-step gradient, from black to red to white, just to show | ||
// that these gradients need not have four components; two or | ||
// three are possible, too, even if they don't look quite as nice for fire. | ||
// | ||
// The dynamic palette shows how you can change the basic 'hue' of the | ||
// color palette every time through the loop, producing "rainbow fire". | ||
|
||
CRGBPalette16 gPal; | ||
|
||
void setup() { | ||
delay(3000); // sanity delay | ||
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); | ||
FastLED.setBrightness( BRIGHTNESS ); | ||
|
||
// This first palette is the basic 'black body radiation' colors, | ||
// which run from black to red to bright yellow to white. | ||
gPal = HeatColors_p; | ||
|
||
// These are other ways to set up the color palette for the 'fire'. | ||
// First, a gradient from black to red to yellow to white -- similar to HeatColors_p | ||
// gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::White); | ||
|
||
// Second, this palette is like the heat colors, but blue/aqua instead of red/yellow | ||
// gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua, CRGB::White); | ||
|
||
// Third, here's a simpler, three-step gradient, from black to red to white | ||
// gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::White); | ||
|
||
} | ||
|
||
void loop() | ||
{ | ||
// Add entropy to random number generator; we use a lot of it. | ||
random16_add_entropy( random()); | ||
|
||
// Fourth, the most sophisticated: this one sets up a new palette every | ||
// time through the loop, based on a hue that changes every time. | ||
// The palette is a gradient from black, to a dark color based on the hue, | ||
// to a light color based on the hue, to white. | ||
// | ||
// static uint8_t hue = 0; | ||
// hue++; | ||
// CRGB darkcolor = CHSV(hue,255,192); // pure hue, three-quarters brightness | ||
// CRGB lightcolor = CHSV(hue,128,255); // half 'whitened', full brightness | ||
// gPal = CRGBPalette16( CRGB::Black, darkcolor, lightcolor, CRGB::White); | ||
|
||
|
||
Fire2012WithPalette(); // run simulation frame, using palette colors | ||
|
||
FastLED.show(); // display this frame | ||
FastLED.delay(1000 / FRAMES_PER_SECOND); | ||
} | ||
|
||
|
||
// Fire2012 by Mark Kriegsman, July 2012 | ||
// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY | ||
//// | ||
// This basic one-dimensional 'fire' simulation works roughly as follows: | ||
// There's a underlying array of 'heat' cells, that model the temperature | ||
// at each point along the line. Every cycle through the simulation, | ||
// four steps are performed: | ||
// 1) All cells cool down a little bit, losing heat to the air | ||
// 2) The heat from each cell drifts 'up' and diffuses a little | ||
// 3) Sometimes randomly new 'sparks' of heat are added at the bottom | ||
// 4) The heat from each cell is rendered as a color into the leds array | ||
// The heat-to-color mapping uses a black-body radiation approximation. | ||
// | ||
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot). | ||
// | ||
// This simulation scales it self a bit depending on NUM_LEDS; it should look | ||
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking. | ||
// | ||
// I recommend running this simulation at anywhere from 30-100 frames per second, | ||
// meaning an interframe delay of about 10-35 milliseconds. | ||
// | ||
// Looks best on a high-density LED setup (60+ pixels/meter). | ||
// | ||
// | ||
// There are two main parameters you can play with to control the look and | ||
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used | ||
// in step 3 above). | ||
// | ||
// COOLING: How much does the air cool as it rises? | ||
// Less cooling = taller flames. More cooling = shorter flames. | ||
// Default 55, suggested range 20-100 | ||
#define COOLING 55 | ||
|
||
// SPARKING: What chance (out of 255) is there that a new spark will be lit? | ||
// Higher chance = more roaring fire. Lower chance = more flickery fire. | ||
// Default 120, suggested range 50-200. | ||
#define SPARKING 120 | ||
|
||
|
||
void Fire2012WithPalette() | ||
{ | ||
// Array of temperature readings at each simulation cell | ||
static byte heat[NUM_LEDS]; | ||
|
||
// Step 1. Cool down every cell a little | ||
for( int i = 0; i < NUM_LEDS; i++) { | ||
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); | ||
} | ||
|
||
// Step 2. Heat from each cell drifts 'up' and diffuses a little | ||
for( int k= NUM_LEDS - 1; k >= 2; k--) { | ||
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; | ||
} | ||
|
||
// Step 3. Randomly ignite new 'sparks' of heat near the bottom | ||
if( random8() < SPARKING ) { | ||
int y = random8(7); | ||
heat[y] = qadd8( heat[y], random8(160,255) ); | ||
} | ||
|
||
// Step 4. Map from heat cells to LED colors | ||
for( int j = 0; j < NUM_LEDS; j++) { | ||
// Scale the heat value from 0-255 down to 0-240 | ||
// for best results with color palettes. | ||
byte colorindex = scale8( heat[j], 240); | ||
CRGB color = ColorFromPalette( gPal, colorindex); | ||
int pixelnumber; | ||
if( gReverseDirection ) { | ||
pixelnumber = (NUM_LEDS-1) - j; | ||
} else { | ||
pixelnumber = j; | ||
} | ||
leds[pixelnumber] = color; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
+#include <FastLED.h> | ||
|
||
#define NUM_LEDS 400 | ||
#define DATA_PIN 16 | ||
|
||
#define LED_TYPE WS2812B | ||
|
||
#define MAX_BRIGHTNESS 200 // Thats full on, watch the power! | ||
#define MIN_BRIGHTNESS 0 // set to a minimum of 25% | ||
const int brightnessInPin = A4; // The Analog input pin that the brightness control potentiometer is attached to. | ||
|
||
// Define the array of leds | ||
CRGB leds[NUM_LEDS]; | ||
|
||
|
||
void setup() | ||
{ | ||
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); | ||
|
||
|
||
// FastLED.addLeds(leds, NUM_LEDS); | ||
} | ||
|
||
void loop() | ||
{ | ||
int mappedValue = map(analogRead(brightnessInPin), 30, 1023, 0, 255); | ||
FastLED.setBrightness(constrain(mappedValue, MIN_BRIGHTNESS, MAX_BRIGHTNESS)); | ||
|
||
fill_solid(leds, NUM_LEDS, CRGB::Red); // Set all to ##GREEN##. | ||
|
||
FastLED.show(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <FastLED.h> | ||
|
||
#define NUM_LEDS_CHA 400 | ||
#define DATA_PIN_CHA 16 | ||
|
||
#define NUM_LEDS_CHB 400 | ||
#define DATA_PIN_CHB 17 | ||
|
||
#define LED_TYPE WS2812B | ||
|
||
#define MAX_BRIGHTNESS 200 // Thats full on, watch the power! | ||
#define MIN_BRIGHTNESS 0 // set to a minimum of 25% | ||
const int brightnessInPin = A4; // The Analog input pin that the brightness control potentiometer is attached to. | ||
|
||
// Define the array of leds | ||
CRGB leds_A[NUM_LEDS_CHA]; | ||
CRGB leds_B[NUM_LEDS_CHB]; | ||
|
||
void setup() | ||
{ | ||
FastLED.addLeds<WS2812B, DATA_PIN_CHA, RGB>(leds_A, NUM_LEDS_CHA); | ||
FastLED.addLeds<WS2812B, DATA_PIN_CHB, RGB>(leds_B, NUM_LEDS_CHB); | ||
|
||
|
||
// FastLED.addLeds(leds, NUM_LEDS); | ||
} | ||
|
||
void loop() | ||
{ | ||
int mappedValue = map(analogRead(brightnessInPin), 30, 1023, 0, 255); | ||
FastLED.setBrightness(constrain(mappedValue, MIN_BRIGHTNESS, MAX_BRIGHTNESS)); | ||
|
||
fill_solid(leds_A, NUM_LEDS_CHA, CRGB::Red); // Set all to ##GREEN##. | ||
fill_solid(leds_B, NUM_LEDS_CHB, CRGB::Red); // Set all to ##GREEN##. | ||
|
||
FastLED.show(); | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
CODES/BACKLIGHT_LED_GREEN_2ch_Test_2_LEDS/BACKLIGHT_LED_GREEN_2ch_Test_2_LEDS.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <FastLED.h> | ||
|
||
#define NUM_LEDS_CHA 400 | ||
#define DATA_PIN_CHA 16 | ||
|
||
#define NUM_LEDS_CHB 400 | ||
#define DATA_PIN_CHB 17 | ||
|
||
#define LED_TYPE WS2812B | ||
|
||
#define MAX_BRIGHTNESS 200 // Thats full on, watch the power! | ||
#define MIN_BRIGHTNESS 0 // set to a minimum of 25% | ||
const int brightnessInPin = A4; // The Analog input pin that the brightness control potentiometer is attached to. | ||
|
||
// Define the array of leds | ||
CRGB leds_A[NUM_LEDS_CHA]; | ||
CRGB leds_B[NUM_LEDS_CHB]; | ||
|
||
void setup() | ||
{ | ||
FastLED.addLeds<WS2812B, DATA_PIN_CHA, RGB>(leds_A, NUM_LEDS_CHA); | ||
FastLED.addLeds<WS2812B, DATA_PIN_CHB, RGB>(leds_B, NUM_LEDS_CHB); | ||
|
||
|
||
// FastLED.addLeds(leds, NUM_LEDS); | ||
} | ||
|
||
void loop() { | ||
|
||
green(); | ||
flash(); | ||
} | ||
void green() { | ||
int mappedValue = map(analogRead(brightnessInPin), 30, 1023, 0, 255); | ||
FastLED.setBrightness(constrain(mappedValue, MIN_BRIGHTNESS, MAX_BRIGHTNESS)); | ||
|
||
fill_solid(leds_A, NUM_LEDS_CHA, CRGB::Red); // Set all to ##GREEN##. | ||
fill_solid(leds_B, NUM_LEDS_CHB, CRGB::Red); // Set all to ##GREEN##. | ||
|
||
FastLED.show(); | ||
} | ||
void flash() | ||
{ | ||
leds_A[0] = CRGB::Green; | ||
FastLED.show(); | ||
delay(500); | ||
leds_A[1] = CRGB::Green; | ||
FastLED.show(); | ||
leds_A[0] = CRGB(0, 0, 0); | ||
FastLED.show(); | ||
delay(500); | ||
leds_A[1] = CRGB(0, 0, 0); | ||
FastLED.show(); | ||
} |
66 changes: 66 additions & 0 deletions
66
CODES/BACKLIGHT_LED_GREEN_2ch_Test_2_SPIN/BACKLIGHT_LED_GREEN_2ch_Test_2_SPIN.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <FastLED.h> | ||
|
||
#define NUM_LEDS_CHA 52 | ||
#define DATA_PIN_CHA 16 | ||
|
||
|
||
|
||
#define LED_TYPE WS2812B | ||
|
||
#define MAX_BRIGHTNESS 150 | ||
#define MIN_BRIGHTNESS 0 | ||
const int brightnessInPin = A4; // The Analog input pin that the brightness control potentiometer is attached to. | ||
|
||
// Define the array of leds | ||
|
||
int GRN; // GREEN LEDS | ||
int RD; // RED LEDS | ||
|
||
int spinPanel[ ] = {0, 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, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}; | ||
int flashRed[ ] = {29, 36}; | ||
int i; | ||
int dim; | ||
|
||
CRGB leds_A[NUM_LEDS_CHA]; | ||
|
||
void setup() | ||
{ | ||
// FastLED[0]; | ||
FastLED.addLeds<WS2812B, DATA_PIN_CHA, RGB>(leds_A, NUM_LEDS_CHA); | ||
} | ||
|
||
void loop() { | ||
green(); | ||
spin(); | ||
} | ||
void green() { | ||
int dim = map(analogRead(brightnessInPin), 0, 1023, 0, 160); | ||
for (i = 0; i < 50; i++) | ||
{ | ||
leds_A[spinPanel[i]] = CHSV( 0, 255, dim); | ||
} | ||
FastLED.show(); | ||
} | ||
void spin() { | ||
static unsigned long lastTime = 0; | ||
const long interval = 250; | ||
static bool state = 0; | ||
|
||
unsigned long now = millis(); | ||
|
||
if ( now - lastTime > interval && state == 0) { | ||
state = 1; | ||
lastTime = now; | ||
leds_A[29] = CHSV( 96, 255, 255); | ||
leds_A[36] = CHSV( 96, 255, 255); | ||
FastLED.show(); | ||
} | ||
|
||
if ( now - lastTime > interval && state == 1) { | ||
state = 0; | ||
lastTime = now; | ||
leds_A[29] = CRGB::Black; | ||
leds_A[36] = CRGB::Black; | ||
FastLED.show(); | ||
} | ||
} |
Oops, something went wrong.