Multiple pushbuttons for different parts of code?

Hi! I'm new to Arduino. Know very little about programming, and have tried some ideas but have trouble compiling a working code.After spending days searching the Internet decided to as for help to you guys.

So I'm building an Arduino metronome to help me and other musicians keep within the tempo.
As a base i am using a knight rider like code with 7led's.

int pinArray[] = {2, 3, 4, 5, 6, 7, 8};
int count = 0;
int timer = 10;

void setup(){
  for (count=0;count<7;count++) {
    pinMode(pinArray[count], OUTPUT);
  }
}

void loop() {
  for (count=0;count<6;count++) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count + 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);
  }
  for (count=6;count>0;count--) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count - 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);
  }
}

by changing the int timer value - the speed of leds flashing should change. I plan to copy/paste the code 5 times with different timer value to achieve different speeds/tempos

the idea is to use 5difrent pushbuttons to activate 5 different tempos (most often used).

for example - if the button1 is pushed then a tempo1 begins
if a button2 is pushed the first tempo stops and a different one begins and so on!

Would greatly appreciate any help with the code.
Thanks in advance.

So - take the pushbuttons, and connect one side of each button to ground, other side to an Arduino pin. Set the pinMode() for the pins to INPUT_PULLUP. When the button is pressed, digitalRead() on the pin will return 0/LOW, otherwise 1/HIGH. Then just check them in loop, and if one is pressed, change the tempo to the appropriate tempo.

You will, however, find that it isn't very responsive, because it spends so much time in delay() - take a look at "blink without delay" and the multiple things at once thread ( Demonstration code for several things at the same time - Project Guidance - Arduino Forum ).

Bruts:
I plan to copy/paste the code 5 times with different timer value to achieve different speeds/tempos

Bad Idea.

Just introduces 5 more places for errors.

Use one piece of code and use a variable to identify the different timings that it should use.

As well as the references DR Azzy gave you, you may find some useful stuff in planning and implementing a program.

...R

You know, give the current time millis() and the tempo, it's reasonably easy to work out which LED should be on. You have 7 LEDs, so the full cycle is 12 LED steps long (this is two beats of the tempo).

const int NUM_LEDS = 7;
const int NUM_LEDS_HALFWAY = NUM_LEDS - 1;
const int NUM_TEMPO_STEPS = NUM_LEDS_HALFWAY * 2;

we'll just round off the length of the number of clicks per two beats to the nearest millisecond:

const int TEMPObpm = 80;
const unsigned long TWO_BEATSms = 60L * 1000L * 2 / TEMPObpm;

I use 'L' to indicate that I want the compiler to use long values, because the maximum value of an int exceeds 120000.

So now we need to work out what to do in the loop.

void loop() {
  unsigned int twoBeatPosition_ms = millis() % TWO_BEATSms;
  unsigned int twoBeatPosition_led = twoBeatPosition * NUM_TEMPO_STEPS / TWO_BEATSms;

So now we have a value twoBeatPosition_led which will vary from 0 to 11, indicating which LED should be on. Of course, for numbers >= NUM_LEDS we need to reverse this:

  if(twoBeatPosition_led >= NUM_LEDS_HALFWAY) {
    twoBeatPosition_led = NUM_TEMPO_STEPS - twoBeatPosition_led;
  }

This means that the led that is supposed to be on "now" is pinArray[twoBeatPosition_led].