Neopixel lauflicht mit taster Starten?

Hallo, hab mir ein kleines Programm für Arduino geschrieben, welches einen Neopixel Led streifen leuchten lässt. Jetzt würde ich gerne das ganze über einen Tastendruck starten anstatt ein Dauerleuchten zu haben. Leider verzweifele ich an der Taster Funktion ;( Villt kann mir das jemand in meinen Code einbauen.

Danke

    #include <Adafruit_NeoPixel.h>
    #ifdef __AVR__
      #include <avr/power.h>
    #endif
    
    
    #define PIN            6
    #define NUMPIXELS      10
    #define BRIGHTNESS 255
    
    // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
    // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
    // example for more information on possible values.
    Adafruit_NeoPixel pixels = Adafruit_NeoPixel(10, 6, NEO_GRB + NEO_KHZ800);
    
    
    int delayval = 50; // delay for half a second
    
    void setup() 
    {
      pixels.begin(); // This initializes the NeoPixel library.
    }
    
    void loop() {
    
      
      for(int i=0;i<NUMPIXELS;i++) // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
    
      {  
    
        // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
        pixels.setPixelColor(i, pixels.Color(255,130,0)); // Led Gelb
    
        pixels.show(); // This sends the updated pixel color to the hardware.
    
        delay(delayval); // Delay for a period of time (in milliseconds).
    
      }
       for(int i=0;i<NUMPIXELS;i++) // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
    
      {  
    
        // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
        pixels.setPixelColor(i, pixels.Color(0,0,0)); // Led Off 
    
        pixels.show(); // This sends the updated pixel color to the hardware.
    
        delay(delayval); // Delay for a period of time (in milliseconds).
    
      }
    }
Arduino
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.