Go Down

Topic: 8x8 LED Scrolling Display Code Help (Read 168 times) previous topic - next topic

Gouthamkn

May 20, 2015, 07:38 pm Last Edit: May 24, 2015, 04:04 pm by CrossRoads
Hi

I have the following working code which display HI. Can any one help me out to make a program which display ''This is my String''. code should be able to get the individual ascii code and map to the look up data. I have attached the schematic. Please help.

Regards
Gk

Code: [Select]

/*
LED Matrix - Display scrolling text
Version: 1.0
Author: electricteardown (http://insidegadgets.wordpress.com)
Created: 6/11/2010
Last Modified: 6/11/2010

*/
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
//Pin connected to DS of 74HC595
int dataPin = 11;

int counter = 0;
int movement = 0;

int LEDs[8][17] = {  
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}      
};

int letterH[8][8] = {  
 {1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 1, 1, 1, 1, 1, 0},
 {1, 1, 1, 1, 1, 1, 1, 0},
 {1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 0, 0, 0, 1, 1, 0}      
};

int letterI[8][8] = {  
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},
 {0, 0, 0, 1, 1, 0, 0, 0},    
};


void setup() {
 //set pins to output because they are addressed in the main loop
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}

void loop() {
 
 if (movement == 0) {
   int x;
   int y;
   for (x = 0; x < 8; x++) {
     for (y = 0; y < 8; y++) {
       LEDs[x][y+8] = letterH[x][y];
     }
   }
 }
 if (movement == 8) {
   int x;
   int y;
   for (x = 0; x < 8; x++) {
     for (y = 0; y < 8; y++) {
       LEDs[x][y+8] = letterI[x][y];
     }
   }
 }
 
 if (counter % 25 == 0) {
   movement++;
   int x;
   int y;
   for (x = 0; x < 8; x++) {
     for (y = 0; y < 16; y++) {
       LEDs[x][y] = LEDs[x][y+1];
     }
   }  
 }
 if (movement >= 16) {
   counter = 0;
   movement = 0;
 }
 
 lightLED();
 counter++;
}

void lightLED() {
 byte columnbitsToSend = 0;
 byte rowbitsToSend = 0;
 
 int x = 0;
 int y = 0;
 for (x = 0; x < 8; x++) {
   columnbitsToSend = 0;
   rowbitsToSend = 0;
     
   for (y = 0; y < 8; y ++) {
     if (LEDs[x][y] == 1) {
       bitWrite(rowbitsToSend, y, HIGH);
     }
   }
   
   digitalWrite(latchPin, LOW);
   bitWrite(columnbitsToSend, x, HIGH);
   shiftOut(dataPin, clockPin, LSBFIRST, columnbitsToSend);
   shiftOut(dataPin, clockPin, MSBFIRST, rowbitsToSend);
   digitalWrite(latchPin, HIGH);  
   delay(2);
 }
}

(tags added by moderator)

marco_c

You should put your code in code tags.

Firstly you will need to define the bit pattern for the letters that you have in your message, because this code only has the letters H and I. If you want all ASCII characters that will take a while.

The encoding is very wasteful and you will run out of memory quickly unless you compress the data. An int is used to represent a 0 or 1. You can use just one bit and drop the requirements per letter from 8x8 = 64 ints = 128 bytes to just 64 bits, which can be packed into 8 bytes.

For the rest, once you have inserted code tags we will be able to read the software.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Gouthamkn

can you help how to insert code tag?

aarg

  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Go Up