LedControl help!

Hi!

My name is Carl-Johan and i’m a student at the university of Malmö in Sweden - the K3. Me and some fellow students are making an interactive piece of clothing consisting of a sweater with a sewn on LED matrix on the chest and touch sensors on the back. The LEDs will light in different pattern, depending on what input is given on the user’s back.

I’m fiddling with a 8x8 LED matrix via a 7219 at the moment, just for prototyping, and i’m using wayodas LedControl to send data to the chip. Sending data works well, that is sending data once, but when i update the matrix a second time, all LEDs go off!

I was hoping somebody could help me cast som light on this. The basic structure is this:

LedControl lc1=LedControl(12,11,10,1);

void heart(){
Serial.println(“HEART”);

lc1.setLed(0,1,1,true);
lc1.setLed(0,1,2,true);

//and so on…

void showPattern(int nbr){
if (nbr==1){

heart();
}

//and so on…

void setup() {
lc1.shutdown(0,false);
}

void loop () {
lc1.setIntensity(0, 15);
//update nbr here

showPattern(nbr);

}

Kind regards

Carl-Johan

Hi Carl-Johann,
I can’t spot anything striking from the code-fragments. You can send me the whole code by mail if you want me to have a closer look…

Eberhard

Can you post the actual code? i cant tell if nbr is being clobbered… you just have a remark that says // update nbr here … if the value of nbr is not dealt with in in showPattern, then no LED’s will illuminate… I would suggest stuff like this to aid in debugging:

#define DEBUG // comment out for production to save memory

void showPattern(int nbr){
if (nbr==1){

heart();
}
#ifdef DEBUG
else {
displayErrorOnMatrix();
}
#endif
}

#ifdef DEBUG
void displayErrorOnMatrix() {
// indicate there’s an invalid value passed to showPattern()
// show something i can identify on the matrix, like a big x
Serial.println(“ERROR”); // could expand with the actual error code

// Draw an X to indicate an error condition (assuming 8x8 matrix)
// assuming setLed signature is: setLed(?, INT x, INT y, BOOL on_off)
for (int n = 0; n < 8; n++) {
lc1.setLed(0,n,n,true);
lc1.setLed(0,8-n,n,true);
}
#endif

}

Hi!

My name is Carl-Johan and i’m a student at the university of Malmö in Sweden - the K3. Me and some fellow students are making an interactive piece of clothing consisting of a sweater with a sewn on LED matrix on the chest and touch sensors on the back. The LEDs will light in different pattern, depending on what input is given on the user’s back.

I’m fiddling with a 8x8 LED matrix via a 7219 at the moment, just for prototyping, and i’m using wayodas LedControl to send data to the chip. Sending data works well, that is sending data once, but when i update the matrix a second time, all LEDs go off!

I was hoping somebody could help me cast som light on this. The basic structure is this:

LedControl lc1=LedControl(12,11,10,1);

void heart(){
Serial.println(“HEART”);

lc1.setLed(0,1,1,true);
lc1.setLed(0,1,2,true);

//and so on…

void showPattern(int nbr){
if (nbr==1){

heart();
}

//and so on…

void setup() {
lc1.shutdown(0,false);
}

void loop () {
lc1.setIntensity(0, 15);
//update nbr here

showPattern(nbr);

}

Kind regards

Carl-Johan