Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Help needed: direct drive LED matrix  (Read 1290 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was playing with this example:
http://www.arduino.cc/playground/Main/DirectDriveLEDMatrix

In the first code, it is rolling text to the left.

I am wondering what do I need to change to make it be able to roll the text to the other directions, such as right/up/down.

Hope those programming masters in this forum can help me out.

Thanks,
Designrats
Logged

Connecticut, US
Offline Offline
Edison Member
*
Karma: 2
Posts: 1036
Whatduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void slidePattern(int pattern, int del) {
  for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del);
  }
}

This function on that page is responsible for "sliding" the existing contents of the leds[][] array out of view, and replacing them with another pattern.  In particular, leds[j] = leds[j][i+1]; sets a given LED to the value on its right-- do this for all LEDs in the correct order, and you'll see the whole image shift leftward one spot.  Then the statement leds[j][7] = patterns[pattern][j][0 + l]; deals with an LED in the rightmost column, by filling it with the appropriate cell in the next column of the new pattern.

It's a very straight-forward routine.  You could write three other similar routines that slide the contents in other directions.
Logged

UK
Offline Offline
Sr. Member
****
Karma: 1
Posts: 491
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Back when I wrote this code people were asking about it so I produced a commented version. Hopefully this will help you figure out what to do (also you can see the original thread at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203747843/17#17).

Code:
void slidePattern(int pattern, int del) {
  // Loop 8 times, once for each column of new character to scroll in
  for (int loop = 0; loop < 8; loop++) {
    // First shuffle existing columns 1 to 7 into cols 0 to 6
    for (int i = 0; i < 7; i++) {
      // Do each row of each column
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    // Now copy new column from pattern onto end column of display
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + loop];
    }
    // Wait for a bit
    delay(del);
  } // end loop for each column of new pattern
} // end function

Andrew
« Last Edit: April 02, 2009, 04:30:16 am by Andrew » Logged

Connecticut, US
Offline Offline
Edison Member
*
Karma: 2
Posts: 1036
Whatduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Designrats, if you've tried a bit of tinkering there, but came up with ugly results, then perhaps you might not have noticed a key phrase in my reply:   do this for all LEDs in the correct order.

If you're scrolling columns rightward, you will need to visit all the columns in the opposite order as the given loop, otherwise each copy will damage data you've just written.

Likewise, if you're sliding up or down, then the order you visit the columns isn't important, but the order you copy the rows is key.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried to compile the code but could not succeed

is warning / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
 / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
 / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
 / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

warning is
 / usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected unqualified-id before 'int'

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

/ usr/lib/gcc/avr/4.3.3/../../../avr/include/stdlib.h: 111: error: expected `) 'before' int '

What is the purpose of warning?
how to handle it?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 671
Posts: 51669
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which code?

Did you install (correctly) the FrequencyTimer2 library?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use arduino  0017 and install frequency lib2 ...

in accordance with the already given

so what's my fault?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 671
Posts: 51669
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I've tried to compile the code but could not succeed

What code?
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: