Friday, December 12, 2014

Final post

I finally finish the coding. Here are the codes after I modified from an example.

#define numberOfRows 3
#define numberOfColumns 3
#define numberOfLayers 3
#define numberOfAnodes numberOfRows*numberOfColumns
#define nonUsedAnodes 7
#define nonUsedCathodes 5

int serialAn = 41;
int rclkAn = 39;
int srclkAn = 37;
int srclrAn = 35;

int serialAn1 = 33;
int rclkAn1 = 31;
int srclkAn1 = 29;
int srclrAn1 = 27;

int serialCat = 8;
int rclkCat = 6;
int srclkCat = 4;
int srclrCat = 2;


void setup(){
  //anodes  
  pinMode(serialAn, OUTPUT);
  pinMode(rclkAn, OUTPUT);
  pinMode(srclkAn, OUTPUT);
  pinMode(srclrAn, OUTPUT);
  pinMode(serialAn1, OUTPUT);
  pinMode(rclkAn1, OUTPUT);
  pinMode(srclkAn1, OUTPUT);
  pinMode(srclrAn1, OUTPUT);
  
  //cathodes
  pinMode(serialCat, OUTPUT);
  pinMode(rclkCat, OUTPUT);
  pinMode(srclkCat, OUTPUT);
  pinMode(srclrCat, OUTPUT);
  
  //clearing out the registers
  digitalWrite(srclkAn, LOW);
  digitalWrite(serialAn, LOW);
  digitalWrite(srclrAn, HIGH);
  digitalWrite(rclkAn, LOW);
  digitalWrite(srclrAn, LOW);
  digitalWrite(rclkAn, HIGH);
  digitalWrite(srclrAn, HIGH);
  
  digitalWrite(srclkAn1, LOW);
  digitalWrite(serialAn1, LOW);
  digitalWrite(srclrAn1, HIGH);
  digitalWrite(rclkAn1, LOW);
  digitalWrite(srclrAn1, LOW);
  digitalWrite(rclkAn1, HIGH);
  digitalWrite(srclrAn1, HIGH); 
  
  digitalWrite(srclkCat, LOW);
  digitalWrite(serialCat, LOW);
  digitalWrite(srclrCat, HIGH);
  digitalWrite(rclkCat, LOW);
  digitalWrite(srclrCat, LOW);
  digitalWrite(rclkCat, HIGH);
  digitalWrite(srclrCat, HIGH);
 
}

void loop(){

  for(int i=1; i<=numberOfColumns; i++){
    for(int j=1; j<=numberOfRows; j++){
      for(int k=1; k<=numberOfLayers; k++){
        lightUpOneLed(j,i,k,100);
        }
      }
    } 

}


int offLed;
int onLed;

void lightUpOneLed(int anodeRow, int anodeCol, int cathodeLayer, int lightDuration){
  int anodeNumber= (anodeRow*3-3)+anodeCol;
  //turning on the specific anode
  digitalWrite(rclkAn1, LOW);
  digitalWrite(rclkAn, LOW);
  for(offLed=0; offLed<(nonUsedAnodes+anodeNumber-1) && offLed<8; offLed++){
    digitalWrite(serialAn1, LOW);
    digitalWrite(srclkAn1, HIGH);
    digitalWrite(srclkAn1, LOW);
    }
  for(onLed=0; onLed<(2-anodeNumber); onLed++){
    digitalWrite(serialAn1, HIGH);
    digitalWrite(srclkAn1, HIGH);
    digitalWrite(srclkAn1, LOW);
    }
  for(offLed=0; offLed<(anodeNumber-2); offLed++){
    digitalWrite(serialAn, LOW);
    digitalWrite(srclkAn, HIGH);
    digitalWrite(srclkAn, LOW);
    }
  for(onLed=0; onLed<1 && onLed<(anodeNumber-1); onLed++){
    digitalWrite(serialAn, HIGH);
    digitalWrite(srclkAn, HIGH);
    digitalWrite(srclkAn, LOW);
    }
  for(offLed=0; offLed<(numberOfAnodes-anodeNumber); offLed++){
    digitalWrite(serialAn, LOW);
    digitalWrite(srclkAn, HIGH);
    digitalWrite(srclkAn, LOW);
    }
  digitalWrite(rclkAn1, HIGH);
  digitalWrite(rclkAn, HIGH);
  
  //turning on the specific cathode layer
  digitalWrite(rclkCat, LOW);
  for(offLed=0; offLed<(cathodeLayer-1); offLed++){
    digitalWrite(serialCat, HIGH);
    digitalWrite(srclkCat, HIGH);
    digitalWrite(srclkCat, LOW);
    }
  for(onLed=0; onLed<1; onLed++){
    digitalWrite(serialCat, LOW);
    digitalWrite(srclkCat, HIGH);
    digitalWrite(srclkCat, LOW);
    }
  for(offLed=0; offLed<((numberOfLayers-cathodeLayer)+nonUsedCathodes); offLed++){
    digitalWrite(serialCat, HIGH);
    digitalWrite(srclkCat, HIGH);
    digitalWrite(srclkCat, LOW);
    }
  digitalWrite(rclkCat, HIGH);
  delay(lightDuration);

}//end of lightUpOneLed function





The good news is all the LED I had on my breadboard are working and the LEDs were blinking the way as I expected.  But the bad news is I think somehow I messed up, my arduino shut down on itself. Once I unplug the USB and re-connect it. Only few LED went on but in few second my Arduino board shut down again. One solution is I think it drives too much current somehow and few LEDs are over heated. I honestly don't really know why. I would love if someone can help me and fix it.I totally cannot capture a picture well because the board just shut down so fast. Right now, my board just won't turn on at all. So I played around with it for a few moment. I could smell that something was burning. Once I unplugged few wires. Some LEDs started lighting up brightly. That helps me realize that since I have LEDs at the moment, it cannot handle all the current I drove for it.





Thursday, December 11, 2014


Unfortunately one of the blue LED did not solder well so it broke. Those LED won't work probably since the circuit is not completed.

What I did here was I connected to breadboard together. Then I bend all the cathode horizontally and solder them together, and solder the anodes vertically. Basically the anodes will connect to the breadboard, while all the cathode will connected with the wire from the ground.

Wednesday, December 10, 2014

I did many research on coding. But today I will start soldering all the LEDs together.

Tuesday, December 9, 2014


In Lab, I tried to build a LED matrix, which is going to be a parallel circuit. 

Sunday, December 7, 2014



A friend suggest me to build it in this way. But I think it looks lame. 

Thursday, December 4, 2014