Trying to make an LED game, no idea what this code means

Hey guys i am trying to recreate a game I saw on an old post:

http://forum.arduino.cc/index.php?topic=7697.0

I can get the game to work, but I really don't know what much of the code means. I know the basics it really starts to confuse me with the "int ledPins" and between the whole void loop and endFunction. If you guys could please try and explain this all to me (preferably everything, but only what I listed is needed) It would be greatly appreciated.

Also I am using the serial monitor on the arduino mac app and it is only displaying two letters when the game is over. Any help would be appreciated.

I will also attach my setup.

Code:

#define BUTTON 2
#define LED 0

int ledPins[8] = {3, 4, 5, 6, 7, 8, 9, 10};
double tempo = 300;
int score = 0;
boolean blueLed = false;

void interrupt();
void endFunction();

void setup() {
for ( int i = 0 ; i < 8 ; i++ ) {
pinMode( ledPins , OUTPUT );

  • }*
  • pinMode( LED , OUTPUT );*
  • pinMode( BUTTON , INPUT );*
  • attachInterrupt( 0 , interrupt , FALLING );*
    }
    void loop() {
  • for ( int i = 0 ; i < 7 ; i++ ) {*
    _ digitalWrite( ledPins , HIGH );_
    * delay( tempo );*
    _ digitalWrite( ledPins , LOW );
    * }
    digitalWrite( ledPins[7] , HIGH);
    blueLed = true;
    delay( tempo );
    digitalWrite( ledPins[7] , LOW);
    blueLed = false;
    for ( int i = 6 ; i > 0 ; i-- ) {
    digitalWrite( ledPins , HIGH );
    delay( tempo );
    digitalWrite( ledPins , LOW );
    }
    }
    void endFunction() {
    Serial.begin(9600);
    Serial.println("game over");
    Serial.print( "Your score: " );
    digitalWrite( LED , HIGH );
    while (1) {
    //game over*

    * }
    }
    void interrupt() {
    delayMicroseconds(20000);
    if ( digitalRead( BUTTON ) == HIGH ) {
    return;
    }
    tempo = tempo * 9 / 10;
    if ( blueLed ) {
    score++;
    }
    else {
    endFunction();
    }
    }*_

In other words, teach you C in a single post. Seem like a tall order. First, please read the two posts at the top of this Forum on the proper way to post code here, especially the use of code tags for the listing. Second, there are tons of free tutorials online that will help you understand C and, hence, what your program is doing. Third, most posters here are more than happy to help people who have expended effort to answer their own question. It appears you haven't made that effort yet. Give it a try and then come back.

I know the basics it really starts to confuse me with the "int ledPins"

To me, "the basics" includes arrays. The int ledPins[] statement defines an array of pin numbers.

between the whole void loop and endFunction.

Between the loop() function and the endFunction() function is a blank line. Does that really need explaining?

sk8ing_cammando:
If you guys could please try and explain this all to me

My simple explanation is:

Your skills in copy-and-paste: perfect

Your skills in C programming: insufficient

So what?