Go Down

Topic: Control via serial led matrix 8x8 (Read 3900 times) previous topic - next topic

arteqw

Feb 07, 2011, 04:30 pm Last Edit: Feb 07, 2011, 04:32 pm by arteqw Reason: 1
Hello!
This is my first post at that forum. I using Arduino about 3 years, and have some experience with it.

I have problem with control via serial console led matrix 8x8 connected do MAX7219 chip. My code is:
Code: [Select]

#include "LedControl.h"

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

void setup() {
 lc.shutdown(0,false);
 /* Set the brightness to a medium values */
 lc.setIntensity(0,3);
 /* and clear the display */
 lc.clearDisplay(0);
 
 Serial.begin(115200);
 Serial.println("Matrix has you!");
}

void loop() {
 byte c;
 if (Serial.available()) {
// read the incoming byte:
c = Serial.read();
               lc.setRow(0,c, B11111111);
}
}


Using console i want to enable selected row on display. What is wrong in ma code ?
Thanks!
Best Regards, Artur

Korman

#1
Feb 07, 2011, 04:38 pm Last Edit: Feb 07, 2011, 04:41 pm by Korman Reason: 1

Using console i want to enable selected row on display. What is wrong in ma code ?


A few questions:


  • Does the function lc.setRow() do what you expect?

  • What kind of data are you sending to the Arduino? Are you typing the keys labelled 0 to 8 to achieve a result or are you sending data via a program? If it's a the first case, try:

Code: [Select]
lc.setRow(0,c % 8, B11111111);

  • What doesn't work?



Korman

arteqw

#2
Feb 07, 2011, 04:48 pm Last Edit: Feb 07, 2011, 04:51 pm by arteqw Reason: 1

Code: [Select]
lc.setRow(0,c % 8, B11111111);
  • What doesn't work?


Thanks, it works!
I sending via serial console numbers form 0 to 7.
Best Regards, Artur

Korman

#3
Feb 07, 2011, 04:53 pm Last Edit: Feb 07, 2011, 04:55 pm by Korman Reason: 1
I just hope you understand why it works and are properly ashamed that with your experience you missed this.

By the way, the code I posted above is a very quick and dirty hack that isn't fit for production, you should handle the read character properly.

Korman

Go Up