Whats happening in this programme ?

Please explain me why we use matrices in this program , and whats happening while using switches. this is program of traffic light system.

// Traffic Lights
// By Ben Hovinga http://ben.hovinga.me/

// Lights {GREEN, YELLOW, RED, PEDGREEN, PEDRED}
int light [2][5] = {{2,3,4,6,7},{8,9,10,12,13}};

// Buttons {light[0],light[1]}
int btn = {5,11};

// Timers
int tgreen = 30000; // 30s
int tyellow = 3000; // 3s
int tred = 3000; // 3s
int tpedwarn = 5000; // 5s (must be less than tgreen)
int tpedwarnint = 500; // 0.5s (must be less than tpedwarn)

// Other Vals. Don’t Change
int btnval = 0;
boolean pedwait = {false,false};
boolean pedactive = {false,false};
int direct = 0;
int stp = 1;
boolean stpset = false;
unsigned long now = 0;
unsigned long changeat = -1;
unsigned long changeatped = -1;
boolean pedredon = true;

// SETUP
void setup() {
// Assign all Pins
for (int x = 0; x < 2; x++){
for (int y = 0; y < 5; y++){
pinMode(light[y], OUTPUT);
}
// Start everything stopped (red)
digitalWrite(light[2], HIGH);
digitalWrite(light[4], HIGH);
}

// Assign buttons
for (int x = 0; x < 2; x++){
pinMode(btn, INPUT);
}
}

// RUN
void loop() {
// Update Time
now = millis();

// Check if button pressed
for (int x = 0; x < 2; x ++){
btnval = digitalRead(btn);
if (btnval == HIGH){
pedwait = true; // We have someone waiting to cross
}
}

// Get into it
switch (stp){
// Green
case 1:
// Setup
if (stpset == false){
changeat = now + tgreen - tpedwarn; // Set timer
// Turn on Ped
if (pedwait[direct] == true){
// Lights change for ped
digitalWrite(light[direct][3], HIGH);
digitalWrite(light[direct][4], LOW);
// Set some vars
pedwait[direct] = false;
pedactive[direct] = true;
pedredon = false;
}
// Turn on Green
digitalWrite(light[direct][0], HIGH);
// Turn off Red
digitalWrite(light[direct][2], LOW);

stpset = true; // We are setup
}
// Run
else{
if (now > changeat){ // Times up
if (pedactive[direct] == true){
// Turn off Ped
digitalWrite(light[direct][3], LOW);
digitalWrite(light[direct][4], HIGH);
pedredon = true;
}
// Next step
stp++;
stpset = false;
}
}
break;
// Warn ped (if possible)
case 2:
// Setup
if (stpset == false){
changeat = now + tpedwarn;
changeatped = now + tpedwarnint;
stpset = true;
}
// Run
else{
// Flash Ped Red
if (pedactive[direct] == true){
if (pedredon == true && changeatped < now){
digitalWrite(light[direct][4], LOW);
pedredon = false;
changeatped = now + tpedwarnint;
}
if (pedredon == false && changeatped < now){
digitalWrite(light[direct][4], HIGH);
pedredon = true;
changeatped = now + tpedwarnint;
}
}
if (now > changeat){ // Times up
// Turn off
digitalWrite(light[direct][0], LOW);
digitalWrite(light[direct][4], HIGH);
pedredon = true;
pedactive[direct] = false;
// Next step
stp++;
stpset = false;
}
}
break;
// Yellow
case 3:
// Setup
if (stpset == false){
changeat = now + tyellow;
digitalWrite(light[direct][1], HIGH);
stpset = true;
}
// Run
else{
if (now > changeat){ // Times up
// Turn off
digitalWrite(light[direct][1], LOW);
// Next step
stp++;
stpset = false;

}
}
break;
// Red
case 4:
// Setup
if (stpset == false){
changeat = now + tred;
digitalWrite(light[direct][2], HIGH);
stpset = true;
}
// Run
else{
if (now > changeat){ // Times up
// Start over
stp = 1;
stpset = false;

// Change Direction
if (direct == 1){
direct = 0;
}
else {
direct = 1;
}
}
}
break;
}
}

siddhu:
Please explain me why we use matrices in this program

Matricies? You mean multidimensional arrays? Because there appears to be two sets of 5 lights. Also, read this:

How to use this forum