Hi all,
i am really new into electronics so i decided to try constructing a led cube as my first project following a tutorial on instructurables (http://www.instructables.com/id/LED-Cube-with-Arduino-and-custom-PCB/). despite i got it to work i have a few problems with the decoders and led matriz response (i figure it as a comunnication problem).
this cube uses 1 decoder to control (tuning on and of) other 4 decoders in charge of driving the 24 columns. all this decoders share a data line for adressing the leds while de layers are driven separatedly through NPN 2222 transistor connected to the UNO.
my problems starts here. if i choose to light a single led or a random single led everithing works, but if i choose to light up for example column 7 (managed by decoder 1) and column 18 (managed by decoder 3) columns 3 and column 22 will also be turned on (i guess this is a problem with the data line swithcing time and the decoders time to actually retrieve and send the data. as C7 ---> y6 pin ---> A1 Low A2 High A3 high and C22 ---> y6 pin ---> A1 Low A2 High A3 from the other decoder that i call to turn C18).
i dont know if i cn control in any way the reading time from the decoders, so i hope someone can help me on this. (by the way next time i will use shift registers)
void displayNum(int num){
//constrain the argument to be between 0 and 24 inclusive.
num = constrain(num, 0, 24);
/*
* AND: selects the bit, the bit at weight will be 1 if the pin is to be high
* >>: shifts the selected bit to the end of the word, making the value a 0 or 1
* first result is lsb
* digitalWrite: write the approptiate result (HIGH or LOW) to the appropriate decoder pin
*/
for(int weight=1, pin=0; pin < DECODER_BITS; weight*=2, pin++)
digitalWrite(decoderPins[pin] ,(num & weight) >> pin);
//delay, this is the absoloute minimum time the light will be displayed.
//ensures adiquate delay for decoders as well.
delayMicroseconds(MICRO);
}
/**
* z < 0: no layers enabled
* 0 < z < LEDS_PER_ROW : only the layer at z will be enabled
* z >= LEDS_PER_ROW: all layers enabled
*/
void cathode(int z){
for(int i = 0; i < LEDS_PER_ROW; i++){
if(i == z || z >= LEDS_PER_ROW){
digitalWrite(cathodePins[i], HIGH);
}else{
digitalWrite(cathodePins[i], LOW);
}
}
}
void displaySquareSmall(int z)
{
cathode(z);
displayNum(7);
displayNum(18);
}
/**
* Stores pin numbers of pins to decoders in array, for iteration
*/
unsigned int decoderPins[] = {p0, p1, p2, p3, p4};
unsigned int cathodePins[] = {Z0, Z1, Z2, Z3, Z4};
#define DECODER_BITS 5
#define LEDS_PER_ROW 5
#define ARDUINO_JUMPERS 5