Pages: [1]   Go Down
Author Topic: 8x8 programming help  (Read 491 times)
0 Members and 1 Guest are viewing this topic.
Deventer
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Can somebody help me with i think is a simple problem.
i broke my mind thinking how to do it.... but haven't found the solution.

I have an 8x8 led matrix working with my arduino.
setup like this: http://marceldunk.blogspot.nl/2012/09/4-leds-with-2-74ch595.html

i want to make a textscroll program. I have this code, but the scroll is not continues...
I want to scroll the next character if the first is full shown-1.
Now it scrolls the character from right to left. When the character left the 8x8led on the left (so 8x8 is clean) than the next character is comming on the right. So i have a gab of 8 positions (maybee 6, i don't want then to get close together)

Code:
//8x8 led//

const int num_rows=8;
const int num_cols=8;

const int clockpinrow=10; //pin 11 van de 74ch595
const int rowdatapin=8; //pin 14 van de 74ch595
const int rowlatchpin=9; //pin 12 van de 74ch595

const int clockpincol=13; //pin 11 van de 74ch595
const int coldatapin=11; //pin 14 van de 74ch595
const int collatchpin=12; //pin 12 van de 74ch595

int printset[2][8]= {0};
int dataset[12][8] = {{
B01111110,
B11000011,
B11000011,
B11000011,
B11000011,
B11000011,
B11000011,
B01111110},
{
B00011000,
B01111000,
B00011000,
B00011000,
B00011000,
B00011000,
B01111110,
B11111111},
{
B00111100,
B01100110,
B00000110,
B00001100,
B00011000,
B00110000,
B11111111,
B11111111},
{
B01111110,
B11000110,
B00000011,
B00111111,
B00111111,
B00000011,
B11000110,
B01111110},
{
B00000011,
B00001111,
B00011011,
B00110011,
B01100011,
B11111111,
B00000011,
B00000011},
{
B01111111,
B11000011,
B11000000,
B01111110,
B00000011,
B00000011,
B00000110,
B11111100},
{
B00000110,
B00001100,
B00011000,
B00110000,
B01111110,
B11000111,
B11000011,
B01111110},
{
B11111110,
B11000011,
B00000011,
B00000011,
B00000011,
B00000011,
B00000011,
B00000011},
{
B01111110,
B11000011,
B11000011,
B01111110,
B01111110,
B11000011,
B11000011,
B01111110},
{
B01111110,
B11000011,
B11000011,
B01111111,
B00000011,
B00000011,
B00000110,
B11111110},
{
B01100110,
B10010010,
B10010010,
B01101111,
B01100011,
B10010101,
B00101111,
B11110001},
{
B00010000,
B00101000,
B00010000,
B00000000,
B00000000,
B00010000,
B00101000,
B00010000}};


void setup() {
  pinMode(clockpinrow, OUTPUT);
  pinMode(clockpincol, OUTPUT);
  pinMode(rowdatapin, OUTPUT);
  pinMode(coldatapin, OUTPUT);
  pinMode(rowlatchpin, OUTPUT);
  pinMode(collatchpin, OUTPUT);
}

void loop() {
     for (int del=0;del<4;del++){
         for (int q=0;q<10;q++){
             for (int b=8;b>-1;b--){
                  for (int a=0;a<8;a++){
                      printset[0][a]=dataset[q][a]>>b;
                      }
                  displayPixels(0,del);
                  }
                  for (int b=1;b<8;b++){
                       for (int a=0;a<8;a++){
                            printset[0][a]=dataset[q][a]<<b;
                            }
                       displayPixels(0,del);
                       }
          }
    }
}

void displayPixels(int val, int delay){
  for (int i=0; i<delay; i++){
    for (int col=0; col<num_cols; col++){
      shiftOut(coldatapin, clockpincol, MSBFIRST, 255-(B00000001 << col));
        digitalWrite(collatchpin, HIGH);
        digitalWrite(collatchpin, LOW);
      int cur =printset[val][col];
      shiftOut(rowdatapin, clockpinrow, MSBFIRST, cur);
        digitalWrite(rowlatchpin, HIGH);
        digitalWrite(rowlatchpin, LOW);
        delayMicroseconds(2000);
    shiftOut(rowdatapin, clockpinrow, MSBFIRST, 0);
      digitalWrite(rowlatchpin, HIGH);
      digitalWrite(rowlatchpin, LOW);
  }
  }
}

So can anybody help me with this program?

Thanks,

Marcel
Logged

Deventer
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have uploaded a video so you can see what i mean:
http://marceldunk.blogspot.nl/2012/12/8x8-led-scroll-text.html
Logged

Deventer
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

okay, i finaly got it to work!!

i work with an int(16b) to display a 8bit(8 leds) led colom.
i bitshift 8 times to the left and then OR this with another int and itself.
like this:
  printset[0][a]=dataset[dispthis][a]<<8;
  printset2[0][a]=printset[0][a]|dataset[dispthis2][a]; 

now i get two characters behind eachother, then scroll them to the left.
When it scrolls 7 times i do the above trick again.
This in a loop will do the thing.

Short video: http://marceldunk.blogspot.nl/2012/12/draaloze-temperatuur-en.html

gr,

Marcel
 
« Last Edit: December 03, 2012, 10:28:04 am by mdunk » Logged

Pages: [1]   Go Up
Jump to: