Kaypad forloop?

Okay so i made this code that works… but it is long. Very long.

I thought that i would translate it to smaller forloops.

But i havent been able to “translate it” to forloops. Or well change it to a forloop.
The code is only one coulomb for a paypad that is 3x3.

  digitalWrite(col1, LOW);
  digitalWrite(col2, HIGH);
  digitalWrite(col3, HIGH);

  reading_row1 = digitalRead(row1);
  reading_row2 = digitalRead(row2);
  reading_row3 = digitalRead(row3);
  reading_row4 = digitalRead(row4);


  if (reading_row1 == LOW)
  {

    reading1++;
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);
    if (reading1 == 1)
    {
      Serial.println("1");
      delay(350);
      reading1 = 0;
    }
  }


  if (reading_row2 == LOW)
  {
    ++reading4;
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    if (reading4 == 1)
    {
      Serial.println("4");
      delay(350);
      reading4 = 0;
    }
  }


  if (reading_row3 == LOW)
  {
    reading7++;
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);

    {
      Serial.println("7");
      delay(350);
      reading7 = 0;
    }
  }

  if (reading_row4 == LOW)
  {
    readingGonger++;
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW);

    {
      Serial.println("*");
      delay(350);
      readingGonger = 0;
    }
  }

Put the columns in an array.
Put the rows in an array.
Possibly you will also want to put the results of digitalRead in an array.

Notes
1)
There is a keypad library.
2)
Post complete code.

Also.. i'm not allowed to use library.

Lexianlex:
Also.. i'm not allowed to use library.

School assignment?

Yeah. I am not looking for the exact answer to anything.. but if i wanted to learn about for loops then i couldve just gone on youtube. But i rather have someone write it to me.

If you have more than two blocks of code (more than three lines each) that are very similar, put that code in a function and call the function.

If you have more than two variables that are the same type, used for the same purpose, and have almost the same name, use an array instead.