Pages: [1]   Go Down
Author Topic: LED screen  (Read 584 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
      }
    }
  }
}


* conections.png (129.17 KB, 629x343 - viewed 23 times.)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25767
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could the flicker be due to the large amount of slow serial data you're outputting?
Logged

"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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you both! I removed the Serial printing and it's now working  smiley
Logged

Pages: [1]   Go Up
Jump to: