Umer Hassan
Newbie level 4
Hello, I am working on LED Dot MATRIX Scrolling Message. I am unable to figure out the logic for scrolling text on the dot matrix. i have write the code for displaying custom text but i am unable to implement it in Scrolling.
Code:
#define shcp PORTB.B0
#define serialdata PORTB.B1
#define stcp PORTB.B2
#define addressbus PORTC
#include<font.h>
unsigned char i,j,k,sd,my_txt_lgth; // 'i' use for stcp loop
// 'j' use for shcp loop
// 'k' use for txt length measure
//'sd' stores single bit by selecting character from font
//array and taking %2.
// my_txt_lgth for storing string length
void clearReg() //shift register clear function
{
for(i=0;i<24;i++)
{
shcp = 0;
serialdata = 0;
shcp = 1;
}
}
void Serialize_And_Display(unsigned char *my_txt) //function for serializing the data
{
my_txt_lgth = strlen(my_txt); //my_txt_lgth holds the number of characters in the strings
for(k=0;k<my_txt_lgth;k++) // enable the only digit with respect to my_txt_lgth
{
for(j=0;j<8;j++) // 2nd loop that select row and latch data
{
stcp = 0; //Storage clock pulse for shift register
for(i=0;i<8;i++) // 1st loop that serialiaze data and store in shift register
{
shcp = 0; //Shift clock pulse for Shift register
sd = (font[*my_txt-32][j]>>i)%2; //Serialize function
serialdata = sd; //send sd on PORTB.B1
shcp = 1; //high the shift clock pulse of shift register
Delay_us(100);
}
addressbus =j; //Select the Rows 1 to 7 of Dotmatrix
stcp = 1;
clearReg();
Delay_us(100);
}
my_txt++; //select the address of next ascii character
}
my_txt = 0; //when all characters are done reset the address
}
void main()
{
TRISB=TRISC=0x00; //PORTS set as output
while(1)
{
Serialize_And_Display("Hello");
}
}