A IR controller just wont work. I
ll keep it with a button. I changed everything to a non delay code for the future if I want to add an other module. Here is my code it works fine. U can use it to if you want a good ledstrip code.
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIXEL_PIN 3
#define PIXEL_COUNT 300
#define BUTTON_PIN 2
#define UNSET -1
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
//variabels
unsigned int mode,oldmode;
unsigned long previousMillis,lastFire,count;
bool oldState = HIGH;
void setup() {
mode = oldmode = count = previousMillis = lastFire = 0;
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin();
strip.show();
Serial.begin(9600);
}
void loop() {
bool newState = digitalRead(BUTTON_PIN);
if((newState == LOW) && (oldState == HIGH)) {
if (millis() - lastFire < 200) {
oldState = newState;
return;
}
lastFire = millis();
newState = digitalRead(BUTTON_PIN);
if(newState == LOW) {
if(++mode > 9) mode = 0;
Serial.println(mode);
}
}
switch(mode) {
case 0:
if(oldmode == mode) colorWipe(strip.Color( 0, 0, 0), 25); // Black/off
else {
previousMillis = 0;
count = 0;
colorWipe(strip.Color( 0, 0, 0), 25); // Black/off
}
break;
case 1:
if(oldmode == mode) colorWipe(strip.Color( 127, 127, 127), 50); // white
else {
resett();
colorWipe(strip.Color( 127, 127, 127), 50); // white
}
break;
case 2:
if(oldmode == mode) colorWipe(strip.Color(255, 0, 0), 50); // Red
else {
resett();
colorWipe(strip.Color(255, 0, 0), 50); // Red
}
break;
case 3:
if(oldmode == mode) colorWipe(strip.Color( 0, 255, 0), 50); // Green
else {
resett();
colorWipe(strip.Color( 0, 255, 0), 50); // Green
}
break;
case 4:
if(oldmode == mode) colorWipe(strip.Color( 0, 0, 255), 50); // Blue
else {
resett();
colorWipe(strip.Color( 0, 0, 255), 50); // Blue
}
break;
case 5:
theaterChase(strip.Color(127, 127, 127), 50); // White
break;
case 6:
theaterChase(strip.Color(127, 0, 0), 50); // Red
break;
case 7:
theaterChase(strip.Color( 0, 0, 127), 50); // Blue
break;
case 8:
if(oldmode == mode) rainbow(10);
else {
resett();
rainbow(10);
}
break;
case 9:
if(oldmode == mode) theaterChaseRainbow(50, false);
else {
resett();
theaterChaseRainbow(50, true);
}
break;
}
oldmode = mode;
oldState = newState;
}
void resett() {
strip.clear();
previousMillis = 0;
count = 0;
}
void colorWipe(uint32_t color, int wait) {
if (millis() - previousMillis >= wait) {
previousMillis = millis();
strip.setPixelColor(count, color);
strip.show();
if(++count >= strip.numPixels()) count = 0;
}
}
void theaterChase(uint32_t color, int wait) {
if (millis() - previousMillis >= wait) {
previousMillis = millis();
strip.clear();
for(int c=count; c<strip.numPixels(); c += 3) {
strip.setPixelColor(c, color);
}
strip.show();
if(++count >= 3) count = 0;
}
}
void rainbow(int wait) {
if (millis() - previousMillis >= wait) {
previousMillis = millis();
for(int i=0; i<strip.numPixels(); i++) {
int pixelHue = count + (i * 65536L / strip.numPixels());
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
}
strip.show();
count += 256;
if(count >= 3*65536) count = 0;
}
}
void theaterChaseRainbow(int wait, bool first) {
int firstPixelHue;
if(first) firstPixelHue = 0;
if (millis() - previousMillis >= wait) {
previousMillis = millis();
strip.clear();
for(int c=count; c<strip.numPixels(); c += 3) {
int hue = firstPixelHue + c * 65536L / strip.numPixels();
uint32_t color = strip.gamma32(strip.ColorHSV(hue));
strip.setPixelColor(c, color);
}
strip.show();
firstPixelHue += 65536 / 90;
if(++count >= 3) count = 0;
}
}
Thanks for the replies