Go Down

Topic: LED screen (Read 701 times) previous topic - next topic

dmm002

Hi all,
I'm building an LED screen. Right now  it's 3x3. The problem is that I'm trying to make it display some images but it doesn't stop flickering. Does anyone know why is it happening? Here is the code I'm using. I'm receiving a String from processing with the states for each LED on. I added an image of the connections at the end of this post

Thanks in advance.


Code: [Select]
char val;
String data = "";

int pinColumn = 11;
int pinRow = 8;

const int ancho = 3;
const int alto = 3;

int leds[ancho*alto];

int matrizLeds[ancho][alto];
int contador = 0;

int temporal[alto];
char recibido[ancho*alto];

int counter = 0;
void setup()
{
  Serial.begin(9600);
  for(int i=8; i<15; i++){
    pinMode(i, OUTPUT);
  }
  for(int i=0; i<ancho*alto; i++){
    leds[i]= 0;
  }
}

void loop()
{
  if (Serial.available())
  {
    val = Serial.read();
    if (val != 'L')
    {   
      recibido[counter] = val;
      leds[counter] = int(recibido[counter]);
      counter++;
    }
    else
    {
      counter = 0;
      contador = 0;
      for(int i=0; i<alto; i++) { // row scan
        for(int j=0; j<ancho; j++) { // column scan
          matrizLeds[i][j] = leds[contador];
         
          contador ++;
        }
      }
    }
  }
  encenderLeds();
  delay(5);
}

void encenderLeds() {
  for(int i=0; i<ancho; i++) { // row scan
    for(int j=0; j<alto; j++) { // column scan
    //Serial.println(matrizLeds[i][j]);
      if(matrizLeds[i][j] == 49){
        Serial.print("entre i=");
        Serial.print(i);
        Serial.print(" j=");
        Serial.println(j);
        digitalWrite(i+pinColumn, HIGH);
        digitalWrite(j+pinRow, LOW);
      }else{
        digitalWrite(i+pinColumn, LOW);
        digitalWrite(j+pinRow, HIGH);
      }
    }
  }
}


AWOL

Could the flicker be due to the large amount of slow serial data you're outputting?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Grumpy_Mike

Drop all the printing.
Read this:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
It is what you are trying to do.

dmm002

Thank you both! I removed the Serial printing and it's now working  :)

Go Up