Unable to break out of "while" loop

Unable to break out of loop shown in code below, have tried "do-while" also but in each case I can not break the loop
Any and all suggestions/comments welcomed.

#include "IRremote.h"
#include "FastLED.h"
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 150
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
#define PIN 6
int direction=1;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);

int r =0;
int x = 47;
int d = 2;
int b=75;
int pos = 0, dir = 1;
int j;

int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 11

IRrecv irrecv(receiver); // create instance of 'irrecv'

decode_results results; // create instance of 'decode_results'

void setup() /----( SETUP: RUNS ONCE )----/

{

Serial.begin(9600);

Serial.println("IR Receiver Raw Data + Button Decode Test");

irrecv.enableIRIn(); // Start the receiver

strip.begin();
strip.show();

}/--(end setup )---/

void loop() /----( LOOP: RUNS CONSTANTLY )----/

{

if (irrecv.decode(&results)) // have we received an IR signal?

{

// Serial.println(results.value, HEX); UN Comment to see raw values

translateIR();

irrecv.resume(); // receive the next value

}

}/* --(end main loop )-- */

void translateIR() // takes action based on IR code received

// describing Car MP3 IR codes

{

switch(results.value)

{

case 0xFFA25D:

Serial.println(" CH- ");

break;

case 0xFF629D:

Serial.println(" CH ");

break;

case 0xFFE21D:

Serial.println(" CH+ ");

break;

case 0xFF22DD:

Serial.println(" PREV ");

break;

case 0xFF02FD:

Serial.println(" NEXT ");

break;

case 0xFFC23D:

Serial.println(" PLAY/PAUSE ");

break;

case 0xFFE01F:

Serial.println(" VOL- ");

break;

case 0xFFA857:

Serial.println(" VOL+ ");

break;

case 0xFF906F:

Serial.println(" EQ ");

break;

case 0xFF6897:

Serial.println(" 0 ");

break;

case 0xFF9867:

Serial.println(" 100+ ");

break;

case 0xFFB04F:

Serial.println(" 200+ ");

break;

case 0xFF30CF:

Serial.println(" 1 ");

break;

case 0xFF18E7:

Serial.println(" 2 ");

break;

case 0xFF7A85:

Serial.println("Larson Shades code");

do
{

larsonscannershades();
}

while ((results.value) == 0xFF7A85);

break;
/*

if ((results.value) == 0xFF7A85)

while( 1 )

larsonscannershades();

break;

*/

case 0xFF10EF:

Serial.println(" 4 ");

break;

case 0xFF38C7:

Serial.println(" 5 ");

break;

case 0xFF5AA5:

Serial.println(" 6 ");

break;

case 0xFF42BD:

Serial.println(" 7 ");

break;

case 0xFF4AB5:

Serial.println(" 8 ");

break;

case 0xFF52AD:

Serial.println(" 9 ");

break;

default:

Serial.println(" other button ");

}

delay(500);

} //END translateIR

/* ( THE END ) */

void larsonscannershades() {

strip.setPixelColor(pos - 2, 0x111111);
strip.setPixelColor(pos - 1, 0X444444);
strip.setPixelColor(pos , 0xFFFFFF);
strip.setPixelColor(pos + 1, 0x444444);
strip.setPixelColor(pos + 2, 0x111111);

strip.show();

delay(1);

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;

}
}

This while loop?

do
       {

         larsonscannershades();
       }

          while ((results.value) == 0xFF7A85);

What is going to make results.value change while the loop is running? Not a damned thing.

please use code tags as stated in the guidelines how to use this forum. ==> The # button above the smiley's.
That improves readability


while ((results.value) == 0xFF7A85);

as long as the results.value does not change in this loop it is stuck there.

robtillaart:
please use code tags as stated in the guidelines how to use this forum. ==> The # button above the smiley's.
That improves readability.

As does removing all those unnecessary blank lines.

You need to use

break;

Or change the value of the data you're comparing the other data to.
Otherwise the while statement will never be false and the loop will keep on going.

That's life, that's C.

Hi,

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom...this will help all of us. :slight_smile: