Code

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

/*

Objective
: To interface with led dot matrix display
Name
: Shreyans jain (shreyans_jain100@rediffmail.co
m)
Software version
: 1.00.01
Micorocontroller used
: AT89S52
Crystal used
: 11.0592MHz
Hardware connections:
Rows of the 5x7 led matrix are connected to the outputs of ULN2003 IC
Columns of 5x7 led matrix are connected to the parallel outputs of the 74HC595 I
C (SIPO)
*/
#include <reg51.h>
/* define 8051 registers */
#include <stdio.h>
/* define I/O functions */
#include <string.h>
/* define strlen function */
sbit ST_Clk = P2^1;
//Storage register clock
sbit SH_Clk = P2^0;
//Shift register clock
sbit Serial_Data = P2^2; //Serial data
void send_data(unsigned int temp)
{
unsigned int Mask = 0x0001, t, Flag;
for (t=0; t<16; t++)
{
Flag = temp & Mask;
if(Flag==0) Serial_Data = 0;
else Serial_Data = 1;
SH_Clk = 1;
SH_Clk = 0;
Mask = Mask << 1;
}
// Apply clock on ST_Clk
ST_Clk = 1;
ST_Clk = 0;
}
void Delay_ms(unsigned int time)
{
unsigned int a,b;
for(a=0;a<time;a++)
for(b=0;b<1275;b++)
;
}
/* CharData is a two dimensional constant array that holds the 8-bit col
umn values of
individual rows for ASCII characters that are to be displayed on a 8x8 matrix
format.*/
const unsigned short CharData[][8] =
{
{00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000}
,
{00000100, 00000100, 00000100, 00000100, 00000100, 00000100, 00000000, 00000100}
,
{00001010, 00001010, 00001010, 00000000, 00000000, 00000000, 00000000, 00000000}
,
{00000000, 00001010, 00011111, 00001010, 00011111, 00001010, 00011111, 00001010}
,
{00000111, 00001100, 00010100, 00001100, 00000110, 00000101, 00000110, 00011100}

,
{00011001,
,
{00000110,
,
{00000100,
,
{00000010,
,
{00001000,
,
{00010101,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000001,
,
{00001110,
,
{00000100,
,
{00001110,
,
{00001110,
,
{00010000,
,
{00011111,
,
{00000111,
,
{00011111,
,
{00001110,
,
{00001110,
,
{00000000,
,
{00000000,
,
{00000001,
,
{00000000,
,
{00010000,
,
{00001110,
,
{00001110,
,
{00001110,
,
{00011110,

00011010, 00000010, 00000100, 00000100, 00001000, 00001011, 00010011}


00001010, 00010010, 00010100, 00001001, 00010110, 00010110, 00001001}
00000100, 00000100, 00000000, 00000000, 00000000, 00000000, 00000000}
00000100, 00001000, 00001000, 00001000, 00001000, 00000100, 00000010}
00000100, 00000010, 00000010, 00000010, 00000010, 00000100, 00001000}
00001110, 00011111, 00001110, 00010101, 00000000, 00000000, 00000000}
00000000, 00000100, 00000100, 00011111, 00000100, 00000100, 00000000}
00000000, 00000000, 00000000, 00000000, 00000110, 00000100, 00001000}
00000000, 00000000, 00000000, 00001110, 00000000, 00000000, 00000000}
00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000100}
00000010, 00000010, 00000100, 00000100, 00001000, 00001000, 00010000}
00010001, 00010011, 00010001, 00010101, 00010001, 00011001, 00001110}
00001100, 00010100, 00000100, 00000100, 00000100, 00000100, 00011111}
00010001, 00010001, 00000010, 00000100, 00001000, 00010000, 00011111}
00010001, 00000001, 00001110, 00000001, 00000001, 00010001, 00001110}
00010000, 00010100, 00010100, 00011111, 00000100, 00000100, 00000100}
00010000, 00010000, 00011110, 00000001, 00000001, 00000001, 00011110}
00001000, 00010000, 00011110, 00010001, 00010001, 00010001, 00001110}
00000001, 00000001, 00000001, 00000010, 00000100, 00001000, 00010000}
00010001, 00010001, 00001110, 00010001, 00010001, 00010001, 00001110}
00010001, 00010001, 00001111, 00000001, 00000001, 00000001, 00000001}
00000100, 00000100, 00000000, 00000000, 00000100, 00000100, 00000000}
00000100, 00000100, 00000000, 00000000, 00000100, 00000100, 00001000}
00000010, 00000100, 00001000, 00001000, 00000100, 00000010, 00000001}
00000000, 00000000, 00011110, 00000000, 00011110, 00000000, 00000000}
00001000, 00000100, 00000010, 00000010, 00000100, 00001000, 00010000}
00010001, 00010001, 00000010, 00000100, 00000100, 00000000, 00000100}
00010001, 00010001, 00010101, 00010101, 00010001, 00010001, 00011110}
00010001, 00010001, 00010001, 00011111, 00010001, 00010001, 00010001}
00010001, 00010001, 00011110, 00010001, 00010001, 00010001, 00011110}

,
{00000111,
,
{00011100,
,
{00011111,
,
{00011111,
,
{00001110,
,
{00010001,
,
{00011111,
,
{00011111,
,
{00010001,
,
{00010000,
,
{00010001,
,
{00010001,
,
{00001110,
,
{00011110,
,
{00001110,
,
{00011110,
,
{00001110,
,
{00011111,
,
{00010001,
,
{00010001,
,
{00010001,
,
{00010001,
,
{00010001,
,
{00011111,
,
{00001110,
,
{00010000,
,
{00001110,
,
{00000100,
,
{00000000,
,
{00001000,

00001000, 00010000, 00010000, 00010000, 00010000, 00001000, 00000111}


00010010, 00010001, 00010001, 00010001, 00010001, 00010010, 00011100}
00010000, 00010000, 00011110, 00010000, 00010000, 00010000, 00011111}
00010000, 00010000, 00011110, 00010000, 00010000, 00010000, 00010000}
00010001, 00010000, 00010000, 00010111, 00010001, 00010001, 00001110}
00010001, 00010001, 00011111, 00010001, 00010001, 00010001, 00010001}
00000100, 00000100, 00000100, 00000100, 00000100, 00000100, 00011111}
00000100, 00000100, 00000100, 00000100, 00000100, 00010100, 00001000}
00010010, 00010100, 00011000, 00010100, 00010010, 00010001, 00010001}
00010000, 00010000, 00010000, 00010000, 00010000, 00010000, 00011111}
00011011, 00011111, 00010101, 00010001, 00010001, 00010001, 00010001}
00011001, 00011001, 00010101, 00010101, 00010011, 00010011, 00010001}
00010001, 00010001, 00010001, 00010001, 00010001, 00010001, 00001110}
00010001, 00010001, 00011110, 00010000, 00010000, 00010000, 00010000}
00010001, 00010001, 00010001, 00010001, 00010101, 00010011, 00001111}
00010001, 00010001, 00011110, 00010100, 00010010, 00010001, 00010001}
00010001, 00010000, 00001000, 00000110, 00000001, 00010001, 00001110}
00000100, 00000100, 00000100, 00000100, 00000100, 00000100, 00000100}
00010001, 00010001, 00010001, 00010001, 00010001, 00010001, 00001110}
00010001, 00010001, 00010001, 00010001, 00010001, 00001010, 00000100}
00010001, 00010001, 00010001, 00010001, 00010101, 00010101, 00001010}
00010001, 00001010, 00000100, 00000100, 00001010, 00010001, 00010001}
00010001, 00001010, 00000100, 00000100, 00000100, 00000100, 00000100}
00000001, 00000010, 00000100, 00001000, 00010000, 00010000, 00011111}
00001000, 00001000, 00001000, 00001000, 00001000, 00001000, 00001110}
00001000, 00001000, 00000100, 00000100, 00000010, 00000010, 00000001}
00000010, 00000010, 00000010, 00000010, 00000010, 00000010, 00001110}
00001010, 00010001, 00000000, 00000000, 00000000, 00000000, 00000000}
00000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00011111}
00000100, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000}

,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000000,
,
{00000010,
,
{00000100,
,
{00001000,
,
{00000000,

00000000, 00000000, 00001110, 00010010, 00010010, 00010010, 00001111}


00010000, 00010000, 00010000, 00011100, 00010010, 00010010, 00011100}
00000000, 00000000, 00001110, 00010000, 00010000, 00010000, 00001110}
00000001, 00000001, 00000001, 00000111, 00001001, 00001001, 00000111}
00000000, 00000000, 00011100, 00010010, 00011110, 00010000, 00001110}
00000011, 00000100, 00000100, 00000110, 00000100, 00000100, 00000100}
00001110, 00001010, 00001010, 00001110, 00000010, 00000010, 00001100}
00010000, 00010000, 00010000, 00011100, 00010010, 00010010, 00010010}
00000000, 00000100, 00000000, 00000100, 00000100, 00000100, 00000100}
00000010, 00000000, 00000010, 00000010, 00000010, 00000010, 00001100}
00010000, 00010000, 00010100, 00011000, 00011000, 00010100, 00010000}
00010000, 00010000, 00010000, 00010000, 00010000, 00010000, 00001100}
00000000, 00000000, 00001010, 00010101, 00010001, 00010001, 00010001}
00000000, 00000000, 00010100, 00011010, 00010010, 00010010, 00010010}
00000000, 00000000, 00001100, 00010010, 00010010, 00010010, 00001100}
00011100, 00010010, 00010010, 00011100, 00010000, 00010000, 00010000}
00001110, 00010010, 00010010, 00001110, 00000010, 00000010, 00000001}
00000000, 00000000, 00001010, 00001100, 00001000, 00001000, 00001000}
00000000, 00001110, 00010000, 00001000, 00000100, 00000010, 00011110}
00010000, 00010000, 00011100, 00010000, 00010000, 00010000, 00001100}
00000000, 00000000, 00010010, 00010010, 00010010, 00010010, 00001100}
00000000, 00000000, 00010001, 00010001, 00010001, 00001010, 00000100}
00000000, 00000000, 00010001, 00010001, 00010001, 00010101, 00001010}
00000000, 00000000, 00010001, 00001010, 00000100, 00001010, 00010001}
00000000, 00010001, 00001010, 00000100, 00001000, 00001000, 00010000}
00000000, 00000000, 00011111, 00000010, 00000100, 00001000, 00011111}
00000100, 00000100, 00000100, 00001000, 00000100, 00000100, 00000010}
00000100, 00000100, 00000100, 00000100, 00000100, 00000100, 00000100}
00000100, 00000100, 00000100, 00000010, 00000100, 00000100, 00001000}
00000000, 00000000, 00001010, 00011110, 00010100, 00000000, 00000000}

};
unsigned int DisplayBuffer[]={0,0,0,0,0,0,0,0};
short i, k, ShiftAmount, scroll, temp, shift_step=1, StringLength;
char message[]="WELCOME TO DELHI TECHNOLOGICAL UNIVERSITY";
char index;
void main()
{
StringLength = strlen(message) ;
do{
for (k=0; k<StringLength; k++)
{
for (scroll=0; scroll<(8/shift_step); scroll++)
{
for (ShiftAmount=0; ShiftAmount<8; ShiftAmount++
)
{
index = message[k];
temp = CharData[index-32][ShiftAmount];
DisplayBuffer[ShiftAmount] = (DisplayBuffer[Shif
tAmount] << shift_step)| (temp >> ((8-shift_step)-scroll*shift_step));
}
for (i=0; i<7; i++)
{
P1 = 0x10000000;
send_data(DisplayBuffer[i]);
Delay_ms(1);
P1 = P1 >>1;
} // i
} // scroll
} // k
}
while(1);
}

You might also like