1
#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?

asked Mar 7, 2023 at 20:00
5
  • you don't have any code for button 3 ... this is a question and answer site ... just ask a question that you would like answered ... Can someone help me please? is not a question about the problem ... besides, what is the point of asking a question that always has a yes answer Commented Mar 7, 2023 at 22:14
  • your code is missing parts... please read arduino.cc/reference/en/language/structure/control-structure/… Commented Mar 8, 2023 at 5:48
  • @jsotola so could you please help me? What is wrong in my code? Yeah i made a mistake it's button 2 not a button 3. Commented Apr 5, 2023 at 9:00
  • Basically I need to jump off the loop after I press another button on IR controller and I can't figure it out. Commented Apr 5, 2023 at 9:01
  • I told you what's wrong with your code on Mar 8 ... it'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? Commented Apr 5, 2023 at 15:32

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.