5x7 LED Matrix on my arduino

Posted by Nikolaus Gradwohl Fri, 03 Apr 2009 04:36:00 GMT

I just hooked up my 5x7 led matrix to an arduino :-)

very cool, i use the led matrix without any other parts as shown in the arduino playground

the next thing i want to do is solder it to one of my protoshields

(ignore the right part of the circuit, it is a currency regulator from another project, but i had no empty breadboards left :-))

ledmatrix

int idx = 0; unsigned long last;

void setup() {
  last = millis();  
  pinMode( 9, OUTPUT );
  pinMode( 10, OUTPUT );
  pinMode( 11, OUTPUT );
  pinMode( 12, OUTPUT );
  pinMode( 13, OUTPUT );

  pinMode( 2, OUTPUT );
  pinMode( 3, OUTPUT );
  pinMode( 4, OUTPUT );
  pinMode( 5, OUTPUT );
  pinMode( 6, OUTPUT );
  pinMode( 7, OUTPUT );
  pinMode( 8, OUTPUT );

   for( int r = 0; r < 7; r++) {
     digitalWrite( r + 2, LOW );
   }
   for( int c = 0; c < 5; c++) {
     digitalWrite( c + 9, HIGH);
   }
}

byte leds[7][5]; 

void setPattern( byte pattern[20][5], int idx ) {
  for( int r =0; r < 7; r++) {
    for( int c = 0; c < 5; c++) {
      leds[r][c] = pattern[r + idx][c];
     }
   } 
}

void draw() {   

  for( int r =0; r < 7; r ++ ) {
    digitalWrite( r + 2, HIGH );
    for( int c=0; c < 5; c ++ ) {
      digitalWrite( 13 - c, ( leds[r][c] == 1 ? LOW : HIGH ));
    }
    delayMicroseconds(900);
    digitalWrite( r + 2, LOW );
  }
}

void loop() {
  if ( millis() - last > 400 ) {
    idx = (idx == 0 ?  7 : 0);
    last = millis();
  }

  byte tmp[14][5] = {
  { 0,0,0,0,0},
  { 0,1,0,1,0},
  { 0,0,0,0,0},
  { 0,1,1,1,0},
  { 0,1,0,1,0},
  { 0,1,1,1,0},
  { 0,0,0,0,0},

  { 0,0,0,0,0},
  { 0,1,0,1,0},
  { 0,0,0,0,0},
  { 0,0,0,0,0},
  { 0,1,1,1,0},
  { 0,0,0,0,0},
  { 0,0,0,0,0},
  };

  setPattern( tmp, idx );
  draw();
}

Tags ,  | 6 comments | no trackbacks

Tweet This! submit to reddit Digg!

Comments

  1. arduinofan said 20 days later:

    Please, You can post exaclty wire in respective pin , because in this photo the pin and wire is not clean

    Tks

  2. arduinofan said 20 days later:

    Please, You can post exactly wire in respective pin , because in this photo the pin and wire is not clean

    Tks

  3. Nikolaus Gradwohl said 20 days later:

    i connected pins 2-8 to the rows of the matrix and pins 9-13 to the columns

    so the cabeling is (left pin of arduino - right pin of knightbright)

    rows 2 - 9, 3 - 14, 4 - 8, 5 - 12 or 5. 6 - 1, 7 - 7, 8 - 2

    columns 9 - 6, 10 - 10, 11 - 4 or 11, 12 - 3, 13 - 13

  4. Fred said 2 months later:

    Dear Nikolaus,

    I just got into this whole Arduino thing and I got this LED Matrix from a friend of mine. Your blog entry is the first thing about this on the internet that looks promising to me. Unfortunately, your last comment - the one, in which you explain the cables - is (sorry for this) very poor. Could you please help me, I'm desperatly looking for a guide here.

    Thanks in advance Fred

    PS: Could you please send it to me via e-mail? That'd be great, thanks!

  5. omar@epejan.com said 8 months later:

    same here, can you post a picture with both sides of the Matrix, to see where pins go, (down side of a designer, graphically oriented) thanks.

  6. onecooldan@gmail.com said 11 months later:

    Great write-up. I'm working on a similar issue with what appears to be an identical LED matrix. If you search for the product info on google, you can find a datasheet with the pin-outs. I believe the manufacturer is Lite-on. I will definitely be back here when I start mine, and I will post anything useful I find.

Trackbacks

Use the following link to trackback from your own site:
http://www.local-guru.net/blog/trackbacks?article_id=5x7-led-matrix-on-my-arduino&day=03&month=04&year=2009

(leave url/email »)

   Comment Markup Help Preview comment