Tuesday, 20 August 2013

5*7 led matrix displaying ALPHABETS..!!!!

Hi friends I am here with the interesting part of the Embedded Projects. Here you will get the codes for the different-different projects copy rights to rajatmelavr@gmail.com...

*******************************************************************************

5*7 LED MATRIX DISPLAYING ALPHABETS

*******************************************************************************
Guys it seem that is is much more easy to make a led matrix and to display the code or the matter you want to display on it is easily task. But seriously it is not that much simple as much as you think it to be, we need to make the proper hardware. It depends, that if you want to make your own hardware then it will be little difficult but will be the best idea for making the own project by your own rather then using the matrix display board.

Each and every time we need to scan either row or the column, here we are scanning the columns.
IT WORKS ON PERSISTENCE OF VISION (POV)...

HARDWARE:

Connection: Connect the PORTA(0-6) to the rows of the matrix.
                   Connect the PORTB(0-4) to the column of the matrix.


In hardware section the led is to be connected in such a way that it will form the matrix for the Mathematics, in which the the connection can be done by you in the way you want. There are two type of the led matrix formation 
1) common  Anode led matrix
2) Common Cathode Led matrix
Here it is connected in the Common Cathode.
The connections are shown in the figure.
Make sure to add 330Ohms resister to each rows.










Software :

Here I had used the ATmega16 as a micro controller. Programmed it on the WinAVR. Make the hexfile and dump it into the IC.

PROGRAMMING :-

BASIC CODE FOR A BEGINNER IN AVR PROGRAMMING WITH C 

********************************************************************


/*PROGRAM TO DISPLAY THE CHARACTER ON LED MATRIX 
AUTHER :- RAJ PRAJAPATI
E-MAIL :- rajatmelavr@gmail.com
*/
******************************************************************************

//HARDWARE CONNECTION
//PORTA => CONNECT TO THE 7 ROWS OF THE MATRIX FOR SENDING THE DATA
//PORTB =>
//PORTC =>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <avr/io.h>
#include <util/delay.h>
int main()
{
DDRA=0xff;
DDRB=0xff;
DDRD=0xff;
while(1)
{
// FOR CHARACTER 'A'
for(int i=1;i<=200;i++)
{
PORTA=0xFE;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x91;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x91;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x91;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xfe;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'B'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x36;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'C'
for(int i=1;i<=200;i++)
{
PORTA=0x3E;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xA2;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'D'
for(int i=1;i<=200;i++)
{
PORTA=0x41;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0xff;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x3e;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'E'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'F'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'G'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x71;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x11;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x73;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'H'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'I'
for(int i=1;i<=200;i++)
{
PORTA=0x41;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'J'
for(int i=1;i<=200;i++)
{
PORTA=0x71;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'K'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x14;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x22;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'L'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'M'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTC=0b11111110;
_delay_ms(1);
PORTA=0x02;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x04;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x02;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'N'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x04;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x10;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);

// FOR CHARACTER 'O'
for(int i=1;i<=200;i++)
{
PORTA=0x3E;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x3E;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'P'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x06;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);

// FOR CHARACTER 'Q'
for(int i=1;i<=200;i++)
{
PORTA=0xFE;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x41;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x51;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x61;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x3E;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'R'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x09;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x19;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x29;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x46;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);

// FOR CHARACTER 'S'
for(int i=1;i<=200;i++)
{
PORTA=0x4F;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x79;
PORTD=0b11101111;
PORTD=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'T'
for(int i=1;i<=200;i++)
{
PORTA=0x01;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'U'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'V'
for(int i=1;i<=200;i++)
{
PORTA=0x1F;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x20;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x40;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x20;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x1F;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'W'
for(int i=1;i<=200;i++)
{
PORTA=0xFF;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x20;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x10;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x20;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0xFF;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'X'
for(int i=1;i<=200;i++)
{
PORTA=0x63;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x14;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x08;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x14;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x63;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'Y'
for(int i=1;i<=200;i++)
{
PORTA=0x01;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x02;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x7C;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x02;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x01;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(1000);
// FOR CHARACTER 'Z'
for(int i=1;i<=200;i++)
{
PORTA=0x61;
PORTD=0b11111110;
PORTB=0b11111110;
_delay_ms(1);
PORTA=0x51;
PORTD=0b11111101;
PORTB=0b11111101;
_delay_ms(1);
PORTA=0x49;
PORTD=0b11111011;
PORTB=0b11111011;
_delay_ms(1);
PORTA=0x45;
PORTD=0b11110111;
PORTB=0b11110111;
_delay_ms(1);
PORTA=0x63;
PORTD=0b11101111;
PORTB=0b11101111;
_delay_ms(2);
}
PORTA=0;
_delay_ms(3000);
}
return 0;
}
******************************************************************************
You can see the video from the following link : 5*7 led matrix VIDEO