Need help with how i can interrupt my led program!

hi this is my first program, so there will be some mistakes!

my problem is when i pust the 9 button on my IR-Remote is runes the code in “button9();” But it have to finish the hole “void button9()” before i can push a nother button, and i need a way to turn it off at any time

so how can i cut off “void button9()” mitway when i push the OFF button on the IR-Remote

Here is my code!

//pin set up
//neopixle   PIN 6
//InFared    PIN 5
//TESTLED    PIN 3
//ledmetrix  PIN 10, 11, 12

//pin names
const int LEDnumber = 2;                          //names pin 2 "LEDnumber"
const int TESTLED = 3;                            //names pin 3 "TESTLED"
const int IR = 5;                                 //names pin 5 "IR"
const int STRIP1 = 6;                             //names pin 6 "STRIP1"

//loads the neopixel library
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LEDnumber, STRIP1, NEO_GRB + NEO_KHZ800);

//loads the ledmatrix library
#include "LedControl.h"
LedControl lc=LedControl(12,10,11,1);

//loads the infared library
#include <IRremote.h>          
IRrecv irrecv(5);
decode_results results;

unsigned long time_since_last_reset = 0;
int pause_one = 1000;
                                                  
void setup()                                      
{                                                 
                                               
  leds.begin();                                   // This initializes the NeoPixel library.
  leds.setBrightness(1);                          //adjust brightness here
  leds.show();                                    // Initialize all pixels to 'off'

  lc.shutdown(0,false);                           // wakeup the matrix 
  lc.setIntensity(0,8);                           // Set the brightness to a medium values
  lc.clearDisplay(0);                             // and clear the display 

  Serial.begin(9600);                             //Open serial 
  irrecv.enableIRIn();                            // Initialization infrared receiver
}                                                 
                                                  
void loop()                                       
{                                                 
                                                  
  if (irrecv.decode(&results))                        //ser efter data fra REMOTE
    {                                               
      Serial.println(results.value, DEC);           //Wrap output in dec receive code
      Serial.println();                             //For ease of viewing the output to add a blank line
                                                  
      switch (results.value)                        //begynder at se efter inbut
        {                   
          case 16724175:                            // hvis 1 bliver trykket 
          button1();
          break;
                     
          case 16732845:                            //hvis 9 bliver trykket                      
          button9();
          break; 

          case 16753245:                            //hvis OFF bliver trykket
          buttonoff();
       }
      
    irrecv.resume();                              //receive the next value from remote
  
  }
}

void button1()
{
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 250, 0, 0);         //sætter pixle 1 (0) til 100% rød 0% grøn 0% blå
  leds.setPixelColor(1, 0, 0, 0);           //sætter pixle 2 (1) til alle på 0%
  leds.show();                              //sender indput til pixle
}

void button2()
{


    
}

void button9()
{
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 250, 0, 0);         //sætter pixle 1 (0) til 100% rød 0% grøn 0% blå
  leds.setPixelColor(1, 0, 0, 0);           //sætter pixle 2 (1) til alle på 0%

  w8_1_sendpixle();
    
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 250, 0, 0);         //sætter pixle 1 (0) til 100% rød 0% grøn 0% blå
  leds.setPixelColor(1, 250, 0, 0);       //sætter pixle 2 (1) til 100% rød 0% grøn 0% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 0, 250, 0);         //sætter pixle 1 (0) til 0% rød 100% grøn 0% blå
  leds.setPixelColor(1, 250, 0, 0);         //sætter pixle 2 (1) til 100% rød 0% grøn 0% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 0, 250, 0);         //sætter pixle 1 (0) til 0% rød 100% grøm 0% blå
  leds.setPixelColor(1, 0, 250, 0);         //sætter pixle 2 (1) til 0% rød 100% grøn 0% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 0, 0, 250);         //sætter pixle 1 (0) til 0% rød 0% grøn 100% blå
  leds.setPixelColor(1, 0, 250, 0);         //sætter pixle 2 (1) til 0% rød 100% grøn 0% blå

  w8_1_sendpixle();
  
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 0, 0, 250);         //sætter pixle 1 (0) til 0% rød 0% grøn 100% blå
  leds.setPixelColor(1, 0, 0, 250);         //sætter pixle 2 (1) til 0% rød 0% grøn 100% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 250, 250, 0);       //sætter pixle 1 (0) til 100% rød 100% grøn 0% blå
  leds.setPixelColor(1, 0, 0, 250);         //sætter pixle 2 (1) til 0% rød 0% grøn 100% blå

  w8_1_sendpixle();
            
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 250, 250, 0);       //sætter pixle 1 (0) til 100% rød 100% grøn 0% blå
  leds.setPixelColor(1, 250, 250, 0);       //sætter pixle 2 (1) til 100% rød 100% grøn 0% blå

  w8_1_sendpixle();
            
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 0, 250, 250);       //sætter pixle 1 (0) til 0% rød 100% grøn 100% blå
  leds.setPixelColor(1, 250, 250, 0);       //sætter pixle 2 (1) til 100% rød 100% grøn 0% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 0, 250, 250);       //sætter pixle 1 (0) til 0% rød 100% grøn 100% blå
  leds.setPixelColor(1, 0, 250, 250);       //sætter pixle 2 (1) til 0% rød 100% grøn 100% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, HIGH);              //tænder TESTLED
  leds.setPixelColor(0, 250, 250, 250);     //sætter pixle 1 (0) til 100% rød 100% grøn 100% blå
  leds.setPixelColor(1, 0, 250, 250);       //sætter pixle 2 (1) til 0% rød 100% grøn 100% blå

  w8_1_sendpixle();
   
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 250, 250, 250);     //sætter pixle 1 (0) til 100% rød 100% grøn 100% blå
  leds.setPixelColor(1, 250, 250, 250);     //sætter pixle 2 (1) til 100% rød 100% grøn 100% blå
  leds.show();                              //sender indput til pixle
                 
}

void buttonoff()
{
  digitalWrite(TESTLED, LOW);               //slukker TESTLED
  leds.setPixelColor(0, 0, 0, 0);     //sætter pixle 1 (0) til 100% rød 100% grøn 100% blå
  leds.setPixelColor(1, 0, 0, 0);     //sætter pixle 2 (1) til 100% rød 100% grøn 100% blå
  leds.show();                              //sender indput til pixle  
}

void w8_1_sendpixle()
{
  time_since_last_reset = millis();
  while((millis() - time_since_last_reset) < pause_one)
    {
      leds.show();                              //sender indput til pixle
    }
}

The trick is not needng interrupts by not spending so much time in w8_1_sendpixle,

my problem is how can i stop a void midway

As a void literally means "a nothing" it can be difficult to stop.

Maybe you want to stop a loop function midway.

If so the answer is to write the code as a state machine that contains no delays and no for or while loops to generate the pattern.

See my http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html Or Robin2's several things at once http://forum.arduino.cc/index.php?topic=223286.0

The problem i have is, when i push the button 9 on my IR-remote it runs

case 16732845: // button 9 in IR-Remote                      
button9();        // runs the led code and here is my problem how do i stop that if i push the OFF button
break;

an the problem is i need to turn if off at any time with the IR-Remote and just go back and lock for a new input!

.

Well, it looks like it's just doing what you tell it to do. If you don't like what it does with button 9, change the code in the function button9().

Gettic: an the problem is i need to turn if off at any time with the IR-Remote and just go back and lock for a new input!

No your real problem is that you have totally ignored all of the answers you have been given.

Grumpy_Mike: No your real problem is that you have totally ignored all of the answers you have been given.

you call that help, i can it "let me google that for you"!, but it's ok i will try a nother forum to get some help. 2 times i have try'd to get help and all i get is a-hols telling me how bad i am and how bad my code locks

so thx to you all for you're time may you have a god day :)

. 2 times i have try'd to get help and all i get is a-hols telling me how bad i am and how bad my code locks

Readers Digest:- You got told that your problem was:-

too much time in w8_1_sendpixle,

You got told the way round that was to:-

the answer is to write the code as a state machine that contains no delays and no for or while loops to generate the pattern.

Why is that not help?

You can not do what you want with your code written like this. It is nothing to do with how your code looks it is to do with what you are telling the processor to do. And it behaving exactly like you are telling it. The fact that it is not doing what you want is down to the fact you are telling it the wrong thing.

you call that help, i can it "let me google that for you"!,

No one gave you that link in this thread.

I provided links to show you how to refactor your code. If you will get off your high horse and listen to what you are being told you would do a lot better than waiting for some one to tell you to just change line X - because that aint going to happen.