Multiple AC Dimmer

Hey guys, I have an AC dimmer created through this website: http://wiki.dxarts.washington.edu/groups/general/wiki/4dd69/

I hooked up a second breadboard with the exact same setup to try to have a second light bulb feed into it and gain control of each one individually, unfortunately I am stuck on the coding aspect it seems because I can get them to dim still but not individually. Right now I am testing it from pin 9 and 10 with just two to start but I am looking to have a good amount by the end.

On a side note... is this the best way to pursue this? Is there any way I could build a sort of switch on a seperate breadboard to do the switching? besides having the information parsed out 5 different times in the serial port like i have now coming from max.

lemme know!

/*
AC Light Control
 
 Updated by Robert Twomey <rtwomey@u.washington.edu>
 
 Changed zero-crossing detection to look for RISING edge rather
 than falling.  (originally it was only chopping the negative half
 of the AC wave form).   
 
 Also changed the dim_check() to turn on the Triac, leaving it on 
 until the zero_cross_detect() turns it off.
 
 Attach AC_PIN output to optotriac input on circuit board.
 Attach Zero Cross Detector output (on circuit board) to Pin 2 (interrupt 0)
 optional LED to pin 3
 Attach arduino GND to GND.
 Attach arduino +5 to +5V.
 
 Attach AC Hot (120v) to AC Hot wire on circuit board.
 Attach AC Neutral to AC Neutral wire on circuit board.
 
 Attach one wire from  bulb to Bulb 1 on circuit board.
 Attach other wire from bulb to Bulb 2 on circuit board (also AC neutral)
 
 details here: http://wiki.dxarts.washington.edu/groups/general/wiki/4dd69/AC_Dimmer_Circuit.html
 
 Thanks to http://www.andrewkilpatrick.org/blog/?page_id=445 
 and http://www.hoelscher-hi.de/hendrik/english/dimmer.htm
 
 */

int dim2 = 0;
int dimLevel = 0;
int dimPick = 0;
int dimPinArray[] = {10,9,8,7,6};
volatile int dimIterArray[5];
int dimLevelArray[5];
unsigned char serIn;
#include <TimerOne.h>           // Avaiable from http://www.arduino.cc/playground/Code/Timer1

volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = 10;                // Output to Opto Triac
int POT_pin = 0;             // Pot for testing the dimming
int LED = 3;                    // LED for testing
int dim = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
int freqStep = 65;    // Set the delay for the frequency of power (65 for 60Hz, 78 for 50Hz) per step (using 128 steps)
// freqStep may need some adjustment depending on your power the formula 
// you need to us is (500000/AC_freq)/NumSteps = freqStep
// You could also write a seperate function to determine the freq

void setup() {                                      // Begin setup
  pinMode(10, OUTPUT);                          // Set the Triac pin as output
  pinMode(9, OUTPUT);       
  pinMode(LED, OUTPUT);                             // Set the LED pin as output
  attachInterrupt(0, zero_cross_detect, RISING);   // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
  Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
  Timer1.attachInterrupt(dim_check, freqStep);
  Serial.begin(19200);  
  
  // Use the TimerOne Library to attach an interrupt
  // to the function we use to check to see if it is 
  // the right time to fire the triac.  This function 
  // will now run every freqStep in microseconds.                                            
}

void zero_cross_detect() {    
  zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured
  for (int i=0; i<1; i++){
    dimIterArray[i]=0;    
    digitalWrite(dimPinArray[i], LOW);                                          
   } 
}                                 

// Function will fire the triac at the proper time
void dim_check() {                   
  if(zero_cross == true) { 
    for (int i=0; i<1; i++){
      if(dimIterArray[i]>=dimLevelArray[i]) {                     
        digitalWrite(dimPinArray[i], HIGH);       
        dimIterArray[i]=0;                         
        zero_cross = false;                
      } 
      else {
        dimIterArray[i] = dimIterArray[i]+1;                           
      }     
    }                                
  }                                  
}                                   

void loop() {                        
  serReadInt(); 
  dimLevelArray[0] = 80;
  dimLevelArray[1] = 120;
  analogWrite(LED, dimIterArray[0]);
  Serial.println(dimLevelArray[1]);
}

int serReadInt()
{
 int i, serAva;                           // i is a counter, serAva hold number of serial available
 char inputBytes[20];  
 char deviceId[20];
 char dimLevel[20];
 // Array hold input bytes
 //char * inputBytesPtr = &inputBytes[0];  // Pointer to the first element of the array
 char * deviceIdPtr = &deviceId[0];
 char * dimLevelPtr = &dimLevel[0];
// char * inputBytesPtr2 = &inputBytes[2];     
 if (Serial.available()>0)            // Check to see if there are any serial input
 {
   delay(5);                              // Delay for terminal to finish transmitted
                                              // 5mS work great for 9600 baud (increase this number for slower baud)
   serAva = Serial.available();  // Read number of input bytes
   for (i=0; i<serAva; i++){       // Load input bytes into array
     inputBytes[i] = Serial.read();
     if (i<1){
     deviceId[0] = inputBytes[0];
     deviceId[1] = '\0';
     }
     else if (i>1){
     dimLevel[i-2] = inputBytes[i];
     dimLevel[i-1] = '\0';
     }
   }
     dimPick = atoi(deviceIdPtr);
     dim2 = atoi(dimLevelPtr);
     dimLevelArray[dimPick] = dim2;
     Serial.print(dimPick+" ");
     Serial.println(dim2);
 }
 else
   return -1;                           // Return -1 if there is no input
}
  for (int i=0; i<1; i++){
    dimIterArray[i]=0;    
    digitalWrite(dimPinArray[i], LOW);                                          
   }

How many times is this loop going to iterate?

    for (int i=0; i<1; i++){
      if(dimIterArray[i]>=dimLevelArray[i]) {                     
        digitalWrite(dimPinArray[i], HIGH);       
        dimIterArray[i]=0;                         
        zero_cross = false;                
      } 
      else {
        dimIterArray[i] = dimIterArray[i]+1;                           
      }     
    }

Or this one?

Loops that iterate once aren't loops.