eine LED nach der anderen über tastendruck

habe von jemanden einen code vorschlag bekommen:

// Number of Button location
int buttonPin = 22;     

// Array of where leds are
int ledPinArray[] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
// Current location in array
int pos = 0;

// read button state
int buttonState = 0;        

void setup() {
  // initialize the LEDs as an output
  for(int i = 0; i < 16; i++) { // Change 4 to length of array
    pinMode(ledPinArray[i],OUTPUT);
  }
  
  // Accept inputs from button pin
  pinMode(buttonPin, INPUT);    
  
  // Turn on the first LED
  digitalWrite(ledPinArray[0],HIGH); 
  digitalWrite(30,HIGH);
  
}

void loop(){
  
  // read the state of the pushbutton
  buttonState = digitalRead(buttonPin);

   // if the button is preseed
  if (buttonState == HIGH) {     

    // increment location in Array
    pos++;
    
    // if the location is higher than the length of the array, set it back to 0
    if(pos >= 16) {
      pos = 0;
    }
    
    // turn on next LED
    digitalWrite(ledPinArray[pos], HIGH);  
    
    // Turns off last LED
    if(pos!=0) { // If the current possition isnt the first in the row
      digitalWrite(ledPinArray[pos-1], LOW);
    } else { // If it is, turn off the last one
      digitalWrite(ledPinArray[15],LOW);
    }
    
    // without this, it will change LED's faster than you can let go of the button
    delay(70);
    
  }

}

das signal des tasters muss nun so getweaked werden das nur eine spitze übrig bleib .. vergleicht mal die zwei unteren abbildungen:

diese kleine spitze ermöglicht das triggern.

eine analoge clock ist ja ne pulswelle die gleichmässig an/aus geht. in der phase AN ... blinken bei diesem code jedoch mehrere leds hintereinander weg. mit dem trigger signal ist es immer nur eine