Hello Friends,
Readily available 5x7
LED modules have no regular sequence of row and columns so we have to spend
some time with PCB and soldering iron.
See the image below - POV effect
LED
Matrix displays are very popular for displaying messages you can see them in everywhere
in your daily routine. For example at railway station - it is used to display
train details, in buses, at restaurants etc. In this post we will make a simple
5x7 LED matrix display and display some messages.
5x7 LED display needs 35 LEDs to make it. We have to
connect all of 35 LEDs with a single microcontroller; here I am using AVR
atmega8 which has 28 pins. If one LED takes one I/O pin of MCU then 35 LEDs
required 35 I/O pins but atmega8 have only 22 I/O pins. Then how we do this??
Answer is MULTIPLEXING.
This technique requires fewer I/O pins of MCU. We need only 12 I/O pins of MCU
to interface this display. To understand that techniques see the figure below.
You can see in the figure that there are 5 column
and 7 rows. All the cathodes are shorted horizontally and all the anodes are
shorted vertically. All the anodes are controlled by columns and all the anodes
are controlled by rows. This structure makes a matrix of 7x5 hence the name ‘LED
Matrix display’ and controlling all the LEDs using this technique called
multiplexing.
For example: If we want to ON led located at (0, 0)
then we have to connect first column to VCC and first Row to Ground. We will
discuss more about this in this post.
Ok! First we have to make this matrix; this requires
patience and lots of time to soldering. See the pics below.
This is my 13x5 LED matrix.
Be careful to make this; the directions of all the
anodes and cathodes should be in correct way otherwise some LEDs will not glow.
You can see in the figure that there is a bridge shape structure which is
complex and many chances to shorting; If you hesitate to make this then don’t worry
there is readily available 5x7 LED display available in the market.See pic below :
This is a 5x7 LED Matrix module common anode type. Let’s
see its pin sequence.
Circuit
Diagram :
We can't connect LEDs directly to supply
hence we have to connect resistance within its path, 470 ohm is sufficient with
5volt supply. Here I am using MCU as current sinking so for current sourcing I placed
4 NPN transistors at columns. Base of transistors are connected to MCU. When
base goes high Emitter to Collector gets shorted and vcc comes at columns.
Take a small piece of zero PCB and make a Header
Board for this LED module. Also place transistors and registers on it. See
images –
Connect a 12 pin female burg strip for Row and
Column Connection.
Now we can directly connect this with our
microcontroller. The purpose of making this is to make it portable so that we
can connect it on the breadboard also. Always try to make things portable so that we don’t have to make them again if repeated.
Make two ribbon cables. One is 7 pin male-to-male
and second is 5 pin male-to-male. See pics :
Connect the cables to 5x7 module and to
Microcontroller with the help of circuit diagram.
Hardware part is completed. Let’s move towards
software part.
To display a character break it in five 8-bit binary
(or hex) sequences. See the image below-
1 -- LED ON 0 -- LED Off
(Note : We configure MCU as current sinking so we have to send invert sequence ~seq[] )
Store the sequences in an array.We have to switch column one by one rapidly. Binary
sequence comes from micro-controller strikes at row pins (R1-R7) and that
time if any column line is active (High) then this sequence will show on that
column. We have to send seq1 to col-1, seq2 to col-2 and so on. If you
don't understand clearly then see the image blow, which is self explanatory.
Columns are switched one by one with some delay and
at the same time binary data comes at row will display on that column line.
**What will happen if we decrease column switching delay
(or increase switching speed)? Yes,
you are thinking right we will see a still image. This phenomenon is known as “Persistence
of Vision”, it gives the illusion that all the LEDs lit at the same
time.
This is the basic concept of this display. See the image below –
See the image below - POV effect
Program:
To display a single character
MCU : Atmega8 @ 16MHz Compiler – WinAVR
Code
:
#define F_CPU 16000000UL
#include<avr/io.h>
#include<util/delay.h>
unsigned char seq[]={
0b01111111,
0b00001001,
0b00001001,
0b00001001,
0b00000110,
};
int main()
{
DDRC=0xFF;
DDRD=0xFF;
PORTC=0;
PORTD=0;
int
i=0;
while(1)
{
for(i=0;i<5;i++)
{
PORTC=(1<<i);
PORTD=~seq[i];
_delay_ms(3);
}
}
return
0;
}
Program
-2: Scrolling Message
The 5x7 hex sequence of all the characters are
stored previously in a header file “font5x7.h” just include it in your main
program and enjoy it. All the characters are stored at its ascii location. So
first convert characters in its ascii value to fetch up sequence from correct
location.
To display moving message we have to maintain a
buffer and store binary sequences of all the characters of our message in it. A
window of sequence 5 will slide continuously at specified time which will show
moving effect.(see ISR section of the code)
Software delay is not accurate so I configure AVR
internal Hardware Timer which is CPU independent. I am using 16-bit Timer1 in compare mode means I can decide
it’s counting boundary according to my requirement. If you are not familiar
with timer go through AVR datasheet or Google it.
Let’s
do some calculation:
A good POV frequency is 400Hz (Flicker Free). Our CPU frequency is
16000000Hz and timer frequency is F_CPU/Prescaler=(16000000/1024)=15625Hz.
So compare value to generate 400Hz is ---
Compare Value = (15625/400)=39.0625
1/400=2.5ms delay means at every 2.5 ms timer interrupt
will strike ISR.
Code
:
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "font5x7.h"
#define LED5x7_DDR DDRD
#define LED5x7_PORT PORTD
#define LED5x7CONTROL_DDR DDRC
#define LED5x7CONTROL_PORT PORTC
unsigned char buffer[];
unsigned int buffer_loc=0;
volatile int count=0,scroll=0,col=0;
//----------------------------------------------------------------
void Scroll_MSG(char *msg)
{
int
i,j=0;
while(*msg!='\0')
{
j=(*msg-32)*5;
for(i=j;i<(j+5);i++)
{
buffer[buffer_loc]=font5x7[i];
buffer_loc++;
}
buffer[buffer_loc]=0;
buffer_loc++;
msg++;
}
}
//----------------------------------------------------------------
void Timer_Init()
{
TCNT1=0;
TIMSK|=(1<<OCIE1A);
OCR1A=39;
TCCR1B|=(1<<CS12)|(1<<CS10)|(1<<WGM12);//F_CPU/1024,CTC
sei();
}
//----------------------------------------------------------------
int main()
{
Timer_Init();
LED5x7_DDR = 0xFF;
LED5x7CONTROL_DDR = 0xFF;
Scroll_MSG(" 5x7LED DISPLAY");
Scroll_MSG(" By-PRATYUSH ");
while(1);
return 0;
}
//----------------------------------------------------------------
ISR(TIMER1_COMPA_vect)
{
count++;
if(count==50){ //to increase scrolling speed decrease counting
count=0;scroll++;
if(scroll>buffer_loc-5)
{scroll=0;}
}
LED5x7CONTROL_PORT = (1<<col);
LED5x7_PORT = ~buffer[scroll+col];
if(col++==4)
{col=0;}
}
//----------------------------------------------------------------
My Pocket Electronic Message card: :)
Video:
~Pratyush Gehlot
ur project fine but i want sms controled scrolling led display can u give me that on my mail if u help me i will help u i am project macker my email devdatta_mhaiskar@in.com
ReplyDeletenice
ReplyDeleteit was really helpfull
ReplyDeleteHi, your project is nice cool! I'm loving this. Now I haven't led 8x8 cathode row, then I have led 8x8 anode row. I need your help about the 74HC595 shift registers with connecting the 16 columns and the 4017 decade counter with UDN2981 rows. Also sending the string message on USART RX/TX. Help me.
ReplyDeleteThese display is microprocessor based Moving Message Display made up of light emitting diode (LEDs) arranged in an array. The Moving Message or data can be fed & set with the help of keypad on chorded remote provided with this unit.For more information visit: http://www.ledtechshop.com
ReplyDeletecan u plz help me to make this to a 15*7 display?
ReplyDeleteThis is a very nice project, it has really help me a lot. the only challenge i have with it now it how to add LED extension to be able to accommodate more LEDs for display.
ReplyDeletePls kindly help me out on this, as per what to do.
Thank You very much.
helpful ......nice share
ReplyDeleteplease give me the circuit diagram and components used for shifting the characters from one matrix to another matrix and simple programming also
ReplyDeletewarm regards
saket
It is nice blog. In Proteus, your string program is not working. Please send me a correct string program. My email is 131061@gmail.com.
ReplyDeleteThis is the blog, that i was searching from like a very long... GRT WORK BRO!!
ReplyDeleteA very well mentioned project on a good projects. Currently i am doing different Led Display projects. These are very tough to do & execute.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletei cant able to view the .hex file
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteur project fine arrow design up/down help me my project code file
ReplyDeleteincredible boss.....ur d best in making things simple......
ReplyDeletei have been exploring many blogs from long time,no one made it as simple as u did...
y dont u help us making a led cube(atleast 3x3 )....
Hi buddy, your blog's design is simple and clean and i like it. Your blog posts are superb. Please keep them coming. Greets!!!
ReplyDeleteMoving Display Board
Nice and very helpful information i have got from your post.
ReplyDeleteled video light
Thank you for posting the great content…I was looking for something like this…I found it quiet interesting, hopefully you will keep posting such blogs….Keep sharing
ReplyDeleteled display
There are certainly a lot of details like that to take into consideration.
ReplyDeleteled display
I just came across to reading your blog it serve very useful information about the interiors thank u
ReplyDeleteTv wall
Post is very informative,It helped me with great information so I really believe you will do much better in the future.
ReplyDeleteDigital Signage Kiosk
This comment has been removed by the author.
ReplyDeleteSir plz explain how the function to scroll is working and why u have done j=(*msg-32)*5. I didn't got this logic.
ReplyDeleteStadium LED Screen
ReplyDelete