Requesting help in understanding programming differences, web page suggests very similar but when I load the code in the NANO module, DIY2 and DIY5 functions fail to stay active, acts like a button was pushed. Loaded same code into UNO module and the function stays active until I select something else. I swapped DIY2 with DIY3 , did the same for DIY5 and DIY6 but changing locations on remote did not solve problem--both DIY's still stop with programming the NANO module.
Open to suggestions and comments
// Binary sketch size: 14,514 bytes (of a 30,720 byte maximum) for loading into NANO
// Binary sketch size: 14,514 bytes (of a 32,256 byte maximum) for loading UNO
#include "IRremote.h"
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
int a = 3;
int c = 0;
int d = 5;
int TOTAL_LEDS = 150;
int r =0;
int x = 0;
int b = 0;
int z = 0;
int y = 0;
int pos = 0, dir = 1;
int j = 0;
int direction=1;
int receiver = 3;
const unsigned long RedLEDinterval2 = 700;
const unsigned long OrangeLEDinterval = 700;
unsigned long RedLEDtimer2;
unsigned long OrangeLEDtimer;
IRrecv irrecv(receiver);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
RedLEDtimer2 = millis ();
OrangeLEDtimer = millis ();
Serial.println("IR Receiver Raw Data + Button Decode Test");
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume();
}
Serial.println(results.value, HEX);
switch(results.value)
{
case 0xFF30CF:
Serial.println("DIY 1");
DIY1();
break;
case 0xFFB04F:
Serial.println("DIY 2");
DIY2();
break;
case 0xFF708F:
Serial.println("DIY 3");
DIY3();
break;
case 0xFF10EF:
Serial.println("DIY 4");
DIY4();
break;
case 0xFF906F:
Serial.println("DIY 5");
DIY5();
break;
case 0xFF50AF:
Serial.println("DIY 6");
DIY6();
break;
default:
Serial.println("Who Are You?");
Serial.println(results.value,HEX);
}
delay(d*50); // d = 5
}
void DIY1(){
int b = 75;
strip.begin();
strip.show();
strip.setBrightness(100);
for (int z = 74, y = 75; z<x, y>r; z++, y--)
{
strip.setPixelColor(z, 150, 150, 150);
strip.setPixelColor(z+1, 150, 150, 150);
strip.setPixelColor(y, 150, 150, 150);
strip.setPixelColor(y-1, 150, 150, 150);
strip.show();
delay(d*10);
strip.setPixelColor(b, 0, 0, 150);
strip.setPixelColor(z, 0, 0, 0);
b++;
strip.setPixelColor(y, 0, 0, 0);
strip.show();
}
strip.setPixelColor(r, 150, 0, 0);
strip.setPixelColor(x, 0, 0, 150);
strip.show();
x--;
r++;
if (x<74)
{
x=75;
}
if (r>76)
{
r=0;
}
delay(d*10);
}
void DIY2(){
if ( (millis () - RedLEDtimer2) >= RedLEDinterval2)
RedWhiteBlue();
}
void DIY3 (){
strip.begin();
strip.show();
strip.setBrightness(100);
strip.setPixelColor(pos - 6, 0x110000);
strip.setPixelColor(pos - 5, 0x880000);
strip.setPixelColor(pos - 4, 0xFF0000);
strip.setPixelColor(pos - 3, 0xFF0000);
strip.setPixelColor(pos - 2, 0XFFFFFF);
strip.setPixelColor(pos - 1, 0XFFFFFF);
strip.setPixelColor(pos , 0xFFFFFF);
strip.setPixelColor(pos + 1, 0xFFFFFF);
strip.setPixelColor(pos + 2, 0xFFFFFF);
strip.setPixelColor(pos + 3, 0x0000FF);
strip.setPixelColor(pos + 4, 0x0000FF);
strip.setPixelColor(pos + 5, 0x000088);
strip.setPixelColor(pos + 6, 0x000011);
strip.show();
for(j=-2; j<= 2; j++)
strip.setPixelColor(pos+j, 0);
pos += dir;
if(pos < 0) {
pos = 1;
dir = -dir;
}
else if(pos >= strip.numPixels())
{
pos = strip.numPixels() - 2;
dir = -dir;
}
}
void DIY4(){
b = 75;
strip.setBrightness(140);
strip.begin();
strip.show();
for (z = 74, y = 75; z<x, y>r; z++, y--)
{
strip.setPixelColor(z, 160, 42, 11);
strip.setPixelColor(z+1, 160, 42, 11);
strip.setPixelColor(y, 160, 42, 11);
strip.setPixelColor(y-1, 160, 42, 11);
strip.show();
delay(d*5);
strip.setPixelColor(b, 30, 5, 0);
strip.setPixelColor(z, 0, 0, 0);
strip.setPixelColor(y, 0, 0, 0);
b++;
strip.show();
}
strip.setPixelColor(r, 30, 5, 0);
strip.setPixelColor(x, 30, 5, 0);
strip.show();
x--;
r++;
if (x<74)
{
x=75;
}
if (r>75)
{
r=0;
}
delay(d*5);
}
void DIY5(){
int TOTAL_LEDS = 150;
float MaximumBrightness = 200;
float SpeedFactor = 0.12;
float StepDelay = 7;
for (int m = 0; m < 100; m++)
{
float intensity = MaximumBrightness /2.0 * (1.0 + sin(SpeedFactor * m));
strip.setBrightness(intensity);
for (int ledNumber=0; ledNumber<TOTAL_LEDS; ledNumber++)
{
strip.setPixelColor(ledNumber, 50, 14, 2);
}
strip.show();
delay(StepDelay);
}
}
void DIY6(){
strip.begin();
strip.show();
strip.setBrightness(100);
strip.setPixelColor(pos - 5, 25, 5, 0);
strip.setPixelColor(pos - 4, 25, 5, 0);
strip.setPixelColor(pos - 3, 25, 5, 0);
strip.setPixelColor(pos - 2, 110, 22, 5);
strip.setPixelColor(pos - 1, 110, 22, 5);
strip.setPixelColor(pos , 110, 22, 5);
strip.setPixelColor(pos + 1, 110, 22, 5);
strip.setPixelColor(pos + 2, 110, 22, 5);
strip.setPixelColor(pos + 3, 25, 5, 0);
strip.setPixelColor(pos + 4, 25, 5, 0);
strip.setPixelColor(pos + 5, 25, 5, 0);
strip.show();
for(j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0);
pos += dir;
if(pos < 0)
{
pos = 1;
dir = -dir;
}
else if(pos >= strip.numPixels())
{
pos = strip.numPixels() - 2;
dir = -dir;
}
}
void RedWhiteBlue(){
// int a = 3
strip.begin();
strip.show();
strip.setBrightness(100);
int SlugDelay = 250;
for (int c = 0; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 100, 0, 0);
strip.show();
delay(SlugDelay);
for (int c = 0; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 0, 0, 0);
strip.show();
delay(SlugDelay);
for (int c = 1; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 100, 100, 100);
strip.show();
delay(SlugDelay);
for (int c = 1; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 0, 0, 0);
strip.show();
delay(SlugDelay);
for (int c = 2; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 0, 0, 100);
strip.show();
delay(SlugDelay);
for (int c = 2; c < TOTAL_LEDS; c = c + a)
strip.setPixelColor(c, 0, 0, 0);
strip.show();
delay(SlugDelay);
}