Problem with a remote control

Hi, before starting: sorry for my english :frowning:

I'm new in this arduino world :slight_smile: and I've been working in some simple tasks to understand the functions and stuff...

Now i'm working with a remote control, just turning on and off 3 leds...

The thing is that i want to press the button 4 and that the leds start to blink repeatedly (using a "while"), but I need that pressing the same button this blink stops. The thing is that it seems that arduino doesn't keep receiving signals with the remote when it's inside this while...

I've been reading about doing this with the millis() function... but I think I don't understand everything about this function...

    if (results.value == 0xFF10EF) { // the condition when I press the button 4
      if (button4 == 0) {
        button4 = 1;
      }
      else if (button4 == 1) {
        button4 = 0;
      }
      while (button4 == 1) {
        analogWrite(redled, HIGH);
        delay(30);
        analogWrite(yelled, HIGH);
        delay(30);
        analogWrite(greled, HIGH);
        delay(30);
        analogWrite(redled, LOW);
        delay(30);
        analogWrite(yelled, LOW);
        delay(30);
        analogWrite(greled, LOW);
        delay(30);
      }
    }

this is what I've done without millis (because whit millis nothing seemed to work :/)

thanks in advance :smiley:

Well i think u could add one reading function in the while funct. And if button state changes to break the cycle u are in(while function)in all the delay is 6x30=180ms so u well need to to keep the button pressed at least 180 ms. so the arduino can get the new info about the button state. And what im saying is that u need to add one read signal function and one if function so arduino can calculate the state and break the while function.

This may not be the perfect decision but at least its something.

One problem is that you are using analogWrite() with the values 0 (LOW) and 1 (HIGH). Those two values are very similar. You should either change to digitalWrite() so that 0 and 1 give you full off and full on or use analogWrite() with 0 and 255 which will also give you full off and full on.