Hardware serial pins 0 & 1 made no difference to response or error message(s).
Would AltSoftSerial make a difference?
Two typical sketches:
/// @file DemoReel100.ino
/// @brief FastLED "100 lines of code" demo reel, showing off some effects
/// @example DemoReel100.ino
#include <FastLED.h>
FASTLED_USING_NAMESPACE
// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
//
// This example also shows one easy way to define multiple
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014
#define DATA_PIN 2
//#define CLK_PIN 4
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 120
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 96
#define FRAMES_PER_SECOND 120
void setup() {
delay(3000); // 3 second delay for recovery
// tell FastLED about the LED strip configuration
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
//FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
}
// List of patterns to cycle through. Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
void loop()
{
// Call the current pattern function once, updating the 'leds' array
gPatterns[gCurrentPatternNumber]();
// send the 'leds' array out to the actual LED strip
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000/FRAMES_PER_SECOND);
// do some periodic updates
EVERY_N_MILLISECONDS( 5 ) { gHue++; } // slowly cycle the "base color" through the rainbow
EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
}
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}
void rainbow()
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, 7);
}
void rainbowWithGlitter()
{
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
addGlitter(80);
}
void addGlitter( fract8 chanceOfGlitter)
{
if( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void confetti()
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}
void bpm()
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
}
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
uint8_t dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
#include <FastLED.h>
#define NUM_LEDS 60
#define LED_PIN 6
#define MAX_SHOTS 5
#define MIN_SHOTS 1
#define SPEED_OF_SHOT random(10,25)
#define MIN_WAIT_BETWEEN_SHOTS 350
#define MAX_WAIT_BETWEEN_SHOTS 700
CRGB leds[NUM_LEDS];
uint8_t colorIndex[NUM_LEDS];
DEFINE_GRADIENT_PALETTE( greenblue_gp ) {
0, 0, 255, 0,
46, 255, 255, 255,
179, 255, 0, 0,
255, 255, 255, 255
};
CRGBPalette16 greenblue = greenblue_gp;
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
Serial.begin(57600);
}
void loop() {
uint32_t period = .1 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
blurPhaseBeat();
}
//uint32_t period1 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
addingWavesandblur();
}
//uint32_t period2 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
movingDotred();
}
//uint32_t period2 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
phaseBeat();
}
//uint32_t period2 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
movingDotgreen();
}
//uint32_t period2 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
shotsbackandforth();
}
//Fill the colorIndex array with random numbers
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i] = random8();
}
//uint32_t period2 = .2 * 60000L; // X minutes
for( uint32_t tStart = millis(); (millis()-tStart) < period; ){
simplecolorpallette();
}
}
void blurPhaseBeat(){
uint8_t sinBeat = beatsin8(30, 0, NUM_LEDS - 1, 0, 0);
uint8_t sinBeat2 = beatsin8(30, 0, NUM_LEDS - 1, 0, 85);
uint8_t sinBeat3 = beatsin8(30, 0, NUM_LEDS - 1, 0, 170);
// If you notice that your pattern is missing out certain LEDs, you
// will need to use the higher resolution beatsin16 instead. In this
// case remove the 3 lines above and replace them with the following:
// uint16_t sinBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
// uint16_t sinBeat2 = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);
// uint16_t sinBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);
leds[sinBeat] = CRGB::Green;
leds[sinBeat2] = CRGB::Blue;
leds[sinBeat3] = CRGB::Red;
EVERY_N_MILLISECONDS(1){
for(int i = 0; i < 4; i++) {
blur1d(leds, NUM_LEDS, 50);
}
}
//fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
}
void addingWavesandblur(){
// Waves for LED position
uint8_t posBeat = beatsin8(30, 0, NUM_LEDS - 1, 0, 0);
uint8_t posBeat2 = beatsin8(60, 0, NUM_LEDS - 1, 0, 0);
uint8_t posBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 127);
uint8_t posBeat4 = beatsin16(60, 0, NUM_LEDS - 1, 0, 127);
// In the video I use beatsin8 for the positions. For longer strips,
// the resolution isn't high enough for position and can lead to some
// LEDs not lighting. If this is the case, use the 16 bit versions below
// uint16_t posBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
// uint16_t posBeat2 = beatsin16(60, 0, NUM_LEDS - 1, 0, 0);
// uint16_t posBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 32767);
// uint16_t posBeat4 = beatsin16(60, 0, NUM_LEDS - 1, 0, 32767);
// Wave for LED color
uint8_t colBeat = beatsin8(45, 0, 255, 0, 0);
// leds[(posBeat + posBeat2) / 2] = CHSV(colBeat, 255, 255);
// leds[(posBeat3 + posBeat4) / 2] = CHSV(colBeat, 255, 255);
leds[(posBeat + posBeat2) /3] = CRGB(colBeat, 0, 0);
leds[(posBeat3 + posBeat4)/2 ] = CRGB(0, colBeat, 0);
fadeToBlackBy(leds, NUM_LEDS, 5);
FastLED.show();
}
void blur(){
EVERY_N_SECONDS(2) {
for (int i = 0; i < 4; i++) {
blur1d(leds, NUM_LEDS, 60);
}
}
EVERY_N_SECONDS(4) {
resetStrip();
}
FastLED.show();
}
void resetStrip() {
// Fill strip with R, G and B stripes
fill_solid(leds, NUM_LEDS, CRGB::Red);
fill_solid(leds, (NUM_LEDS / 3) * 2, CRGB::Green);
fill_solid(leds, (NUM_LEDS / 3), CRGB::White);
}
void movingDotred(){
uint16_t sinBeat = beatsin16(35, 0, NUM_LEDS - 1, 0, 0);
leds[sinBeat] = CRGB::Red;
fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
}
void movingDotgreen(){
uint16_t sinBeat = beatsin16(35, 0, NUM_LEDS - 1, 0, 0);
leds[sinBeat] = CRGB::Green;
fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
}
void phaseBeat(){
uint8_t sinBeat = beatsin8(30, 0, NUM_LEDS - 1, 0, 0);
uint8_t sinBeat2 = beatsin8(30, 0, NUM_LEDS - 1, 0, 85);
uint8_t sinBeat3 = beatsin8(30, 0, NUM_LEDS - 1, 0, 170);
// If you notice that your pattern is missing out certain LEDs, you
// will need to use the higher resolution beatsin16 instead. In this
// case remove the 3 lines above and replace them with the following:
// uint16_t sinBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
// uint16_t sinBeat2 = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);
// uint16_t sinBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);
leds[sinBeat] = CRGB::Green;
leds[sinBeat2] = CRGB::Red;
leds[sinBeat3] = CRGB::White;
fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
}
void shotsbackandforth(){
int numShots = rand() % ((MAX_SHOTS - MIN_SHOTS) + 1) + MIN_SHOTS;
for (int currShot = 1; currShot <= numShots; currShot++)
{
Serial.println("Green shot");
doGreenShot();
}
int range = MAX_WAIT_BETWEEN_SHOTS - MIN_WAIT_BETWEEN_SHOTS;
int delayBetweenShot = rand() % (range) + MIN_WAIT_BETWEEN_SHOTS;
delay(delayBetweenShot);
numShots = rand() % ((MAX_SHOTS - MIN_SHOTS) + 1) + MIN_SHOTS;
for (int currShot = 1; currShot <= numShots; currShot++)
{
Serial.println("Red shot");
doRedShot();
}
range = MAX_WAIT_BETWEEN_SHOTS - MIN_WAIT_BETWEEN_SHOTS;
delayBetweenShot = rand() % (range) + MIN_WAIT_BETWEEN_SHOTS;
delay(delayBetweenShot);
}
/*
* Calls the shoot method with the green parameter
*/
void doGreenShot()
{
int startingPin = 0; // The LED to start at
for (int i = startingPin; i < NUM_LEDS-11; i+=2)
{
fill_solid(leds+i,10, CHSV(random8(),255,255));
FastLED.show(); // Show changes
leds[i] = CRGB::Black; // Set the first one to black
leds[i+1] = CRGB::Black; // Set the first one to black
leds[i+2] = CRGB::Black; // Set the first one to black
leds[i+3] = CRGB::Black; // Set the first one to black
delay(SPEED_OF_SHOT+3);
}
clearEnds();
FastLED.show();
}
/*
* Calls the shoot method with the red parameter
*/
void doRedShot()
{
int startingPin = NUM_LEDS - 10; // The LED to start at
for (int i = startingPin; i >= 0; i-=2)
{
int location = NUM_LEDS - i;
fill_solid(leds + i, 5, CHSV(random8(),255,255));
FastLED.show(); // Show changes
leds[i+7] = CRGB::Black; // Set the first one to black
leds[i+8] = CRGB::Black; // Set the first one to black
leds[i+9] = CRGB::Black; // Set the first one to black
leds[i+10] = CRGB::Black; // Set the first one to black
delay(SPEED_OF_SHOT);
}
clearEnds();
FastLED.show();
}
void clearEnds()
{
for (int i = NUM_LEDS - 1; i >= NUM_LEDS - 12; i--)
{
leds[i] = CRGB::Black;
}
for (int i = 0; i <= 12; i++)
{
leds[i] = CRGB::Black;
}
FastLED.show();
}
void simplecolorpallette(){
// Color each pixel from the palette using the index from colorIndex[]
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(greenblue, colorIndex[i]);
}
EVERY_N_MILLISECONDS(2){
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i]++;
}
}
FastLED.show();
}