following script does not work. Can you correct it for me? /// @file…
- User
following script does not work. Can you correct it for me? /// @file Fire2012WithPalette.ino /// @brief Simple one-dimensional fire animation with a programmable color palette /// @example Fire2012WithPalette.ino
#include <FastLED.h>
#define LED_PIN 6 #define COLOR_ORDER GRB #define CHIPSET WS2811 #define NUM_LEDS 30
#define BRIGHTNESS 100 #define FRAMES_PER_SECOND 60
bool gReverseDirection = false;
int currentPalette = 0; int buttonState = HIGH; int prevButtonState = HIGH;
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 ); pinMode(BUTTON_PIN, INPUT_PULLUP);
// Set initial button state buttonState = digitalRead(BUTTON_PIN); prevButtonState = buttonState;
// 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 A) 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 B) 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 C) gPal = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Yellow);
- Assistant
- User
Thank you. Arduino keeps prompting error messages. Can you make the changes to make the script run normal.
- Assistant
I apologize for the inconvenience caused. Here's the modified script with all the necessary changes to ensure it runs properly without any error messages: