So I got my arduino the other week, started playing with it, found a couple people doing the text scrolling thing and decided I felt like doing it.
So I messaged a few people to figure out the best approach for this using the Tlc5940s and pFETs and alot of wires. One guy on youtube messaged me back with his help and said he was using a modified version of the oomlout code for his tlcs, so I got his code rigged it up to work with my messy wiring and it works, I was just wondering how i could modify it to work with more the one matrix, i got extra tlcs, matrix, and fets. Here the code.
/*
* Example Code for an 8 x 8 LED Matrix
* For More Details Visit http://www.tinyurl.com/yhwxv6h
*
* Scrolls a message across an 8 x 8 LED Matrix
* To adjust the speed change the variable speed.
* The message is held in requestString[]
*/
#include "Tlc5940.h"
int speed = 5; //number of times to repeat each frame
//int pauseDelay = 500; //microseconds to leave each row on before moving to the next
int pauseDelay = 2;
char requestString[] = " Hows life "; //The string to display
//to change the message in code you right yourself simply
//change this data and reset index and offset to 0
//Variables used for scrolling (both start at 0
int index = 0; //this is the current charachter in the string being displayed
int offset = 0; //this is how many columns it is offset by
int rowB[] = {3,2,1,0,15,14,13,12,7,6,5,4,19,18,17,16};
//THE ORDER OF IT IS BECAUSE MY MESSY WIRING.
int rowD[] = {11,10,9,8,23,22,21,20};
int colA[] = {29,30,31,24,25,26,27,28};
//Constants defining each charachters position in an array of integer arrays
//Letters
const int A = 0; const int B = 1; const int C = 2; const int D = 3; const int E = 4;
const int F = 5; const int G = 6; const int H = 7; const int I = 8; const int J = 9;
const int K = 10; const int L =11; const int M = 12; const int N = 13; const int O = 14;
const int P = 15; const int Q =16; const int R = 17; const int S = 18; const int T = 19;
const int U = 20; const int V =21; const int W = 22; const int X = 23; const int Y = 24;
const int Z = 25;
//Punctuation
const int COL =26; const int DASH = 27; const int BRA2 = 28; const int _ = 29; const int LINE = 34;
const int DOT =36;
//Extra Charchters
const int FULL =30; const int CHECK = 31; const int AA3 = 32; const int TEMP = 33;
const int SMILE =35; const int COLDOT = 36;
//The array used to hold a bitmap of the display
//(if you wish to do something other than scrolling marque change the data in this
//variable then display)
byte data[] = {0,0,0,0,0,0,0,0};
//The alphabet
//Each Charachter is an 8 x 7 bitmap where 1 is on and 0 if off
//THIS WAS A ALPHABET BUT GOT RID OF IT CAUSE CHARACTER LIMITS
//Load the bitmap charachters into an array (each charachters position corresponds to its previously defined index (ie _A (a's bitmap)
//is at index 0 and A = 0 so letters[A] will return the 'A' bitmap)
const int* letters[] = {_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,_COL,_DASH,_BRA2,__, _FULL, _CHECK, _AA3, _TEMP, _LINE, _SMILE, _DOT, _COLDOT};
//Setup runs once when power is applied
void setup()
{
Tlc.init();
Tlc.clear();
Tlc.update();
}
//repeats
void loop()
{
updateMatrix();
}
void updateMatrix(){
loadSprite();
showSprite(speed);
}
//An array holding the powers of 2 these are used as bit masks when calculating what to display
const int powers[] = {1,2,4,8,16,32,64,128};
//Loads the current scroll state frame into the data[] display array
void loadSprite(){
int currentChar = getChar(requestString[index]);
int nextChar = getChar(requestString[index+1]);
for(int row=0; row < 8; row++){ //iterate through each row
data[row] = 0; //reset the row we're working on
for(int column=0; column < 8; column++){ //iterate through each column
data[row] = data[row] + ((powers[column] & (letters[currentChar][row] << offset))); //loads the current charachter offset by offset pixels
data[row] = data[row] + (powers[column] & (letters[nextChar][row] >> (8-offset) )); //loads the next charachter offset by offset pixels
}
}
offset++; //increment the offset by one row
if(offset==8){offset = 0; index++; if(index==sizeof(requestString)-2){index=0;}} //if offset is 8 load the next charachter pair for the next time through
}
void showSprite(int speed2){
for(int iii = 0; iii < speed2; iii++){ //show the current frame speed2 times
for(int column = 0; column < 8; column++){ //iterate through each column
for(int i = 0; i < 8; i++){
// Tlc.set(rowD[i], 0); //turn off all row pins
Tlc.set(rowB[i], 0);
// Tlc.set(rowC[i], 0);
Tlc.update();
}
for(int i = 0; i < 8; i++){ //Set only the one pin
if(i == column){ Tlc.set(colA[i], 4095); Tlc.update(); } //turns the current row on
else{ Tlc.set(colA[i], 0); Tlc.update(); }//turns the rest of the rows off
}
for(int row =0; row < 8; row++){ //iterate through each pixel in the current column
int bit = (data[column] >> row) & 1;
if(bit == 1){
// Tlc.set(rowD[row], 4095); //if the bit in the data array is set turn the LED on
Tlc.set(rowB[row], 4095);
// Tlc.set(rowC[row], 4095);
Tlc.update();
//Tlc.update();
}
}
delay(pauseDelay); //leave the column on for pauseDelay microseconds (too high a delay causes flicker)
Tlc.update();
Tlc.update();
}
}
}
//THERE WAS A RETURN INDEX BUT GOT RID OF IT BECAUSE OF THE CHARACTER LIMITS