#include <IRremote.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN 7 // define the LED strip data pin
#define LED_COUNT 150 // define the number of LEDs in the strip
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int RECV_PIN = 2; // define the IR receiver pin
IRrecv irrecv(RECV_PIN);
int brightness = 100;
void setup() {
Serial.begin(9600); // initialize serial communication
strip.begin(); // initialize LED strip
strip.show(); // turn off all LEDs
irrecv.enableIRIn(); // start the receiver
}
void loop() {
case 0xE916FF00: // 0
Serial.println("0");
for (int i = 0; i<LED_COUNT; i++) {
strip.setPixelColor(i, 0, 0, 0); // set all LEDs to off
strip.show(); // turn off all LEDs
Serial.println(irrecv.decodedIRData.decodedRawData);
}
break;
case 0xF30CFF00: // 1
Serial.println("1");
for (int i = 0; i<LED_COUNT; i++) {
strip.setPixelColor(i, 255, 255, 255); // set all LEDs to white
strip.setBrightness(brightness); // set maximum brightness
strip.show(); // display the color on the LED strip
}
break;
case 0xE718FF00: // 2
Serial.println("2");
while (true) {
for (int i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, random(256), random(256), random(256));
}
strip.show();
delay(1000);
if(irrecv.decode()){
break;
}
}
break;
default:
break;
}
irrecv.resume(); // receive the next code
}
}
I have trouble to get out of the loop after i press button 3. When button 1 or 0 is pressed everything works perfectly but when i tried to add animation to my led strip (randomly changing colors) it stops to recieving. I dont know what to do. I expect that after i press button 3 on my controller LED strip will be continously changing colors until another button is pressed (In my case button 0 or 1) Can someone help me please?
Can someone help me please?
is not a question about the problem ... besides, what is the point of asking a question that always has ayes
answerit's button 2 not a button 3
... don't explain in a comment, edit your question and make the correction there ...When button 1 or 0 is pressed everything works perfectly
... how can it work perfectly when the code does not even compile without an error?