0% found this document useful (0 votes)
139 views

Scrolling Text in LED Dot

This document describes how to create a scrolling text display using a 10x8 LED dot matrix display. It explains the concept of multiplexed displays and shows the circuit diagram of the LED dot matrix display. It then provides details on how to program a PIC microcontroller to first display a static letter and then implement scrolling text by shifting the data in a display buffer and continuously refreshing the columns. Sample code is provided to illustrate scrolling individual letters by defining font data functions.

Uploaded by

Ashwani Garg
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

Scrolling Text in LED Dot

This document describes how to create a scrolling text display using a 10x8 LED dot matrix display. It explains the concept of multiplexed displays and shows the circuit diagram of the LED dot matrix display. It then provides details on how to program a PIC microcontroller to first display a static letter and then implement scrolling text by shifting the data in a display buffer and continuously refreshing the columns. Sample code is provided to illustrate scrolling individual letters by defining font data functions.

Uploaded by

Ashwani Garg
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ScrollingtextinLEDdotmatrixdisplay

Introduction:
Multiplexeddisplaysareelectronicdisplayswheretheentiredisplayisnotdrivenatonetime.
Instead,subunitsofthedisplay(typically,rowsorcolumnsforadotmatrixdisplayorindividual
charactersforacharacterorientateddisplay,occasionallyindividualdisplayelements)are
multiplexed,thatis,drivenoneatatime,buttheelectronicsandthepersistenceofvisioncombine
tomaketheviewerbelievetheentiredisplayiscontinuouslyactive.
10x8LEDdotmatrixdisplay:
Belowfigureillustratestheconstructionofa10x8LEDdotmatrixdisplay.

Working:
Intheabovefigure,therowsarenegativeandcolumnsarepositive.Now,ifIconnectasinglecolumn
to positive 3V and a single row to negative (0v), then the LED in place of the intersection of the
correspondingrowandcolumnwillglow.Now,ifweselectasinglecolumn(meansa+voltatselected
column),saycolumn1andmultiplerows(meansconnect0Vtofewselectedrows),sayrow1,2&8,
thentheselected1,2and8LEDsincolumn1willglow.Nowifishiftthecolumn(meansshiftingthe
positivevoltagefromcolumn1tocolumn2),andifichangetherowdata,thenthenewdatawillbe
displayedincolumn2.
Now,ificontinuouslyshiftthecolumnandproviderowdatacorrespondingtoeachcolumn,theni
candisplaythedifferentrowdata(8bit)indifferentcolumns...
.So,ifoneframe(10columnshift)iscompletedwithin1/16thofasecond,thenduetothepersistence
ofvisionofoureye,wewillfeeltheentirecolumnsareactivatedatatime,andthuswewillseeallthe
ten8bitdatacorrespondingtothe10columns,atatime.........
Now,ifasetof8bitdata(say5x8)representsaletter,say,'F'thenwewillseeletter'F'inthe
display.
Circuitexplanation:

Intheabovecircuit,thePIC16F877Aprovidesthe8bitrowdata.CD4017isusedtoselectthecolumn
onebyone.Now,forshiftingthecolumnposition,aclockisprovidedbythePICtotheCD4017.On
everyclock,thecolumnisshifted.(fromrighttoleftinthiscase).
Note:
Here,IusedaPIC16F877AmicrocontrollerandaCD4017johnsoncounter.Butthe40pinPIC16F877Ais
havingmorenumberofPORTpins,andthusthereisnoneedoftheCD4017forthissmalldisplay,andi
couldusesomeotherportpinsofthePICtoworkasajohnsoncounter.Butanyway,iusedaCD4017just
because, in the same circuit board, i could use other free PORT pins for some other purpose like LCD
interfacing,USRT,SPI,PWMetclater...

Programming:
IamusingHiTechCcompilerwithMPLABIDEforcompilingtheembeddedCprogramandthereby
generatingthehexfilewhichistobeloaded/burnedtothePIC.TherearemanyotherCcompilers,but
istartedwithHiTechCandIlikeit.SoIamcontinuingwithit....

Beforedoingascrollingtext,whatididisastillletterdisplay.
Programtodisplayastillletter'F'inthedisplay(example)
/*Todisplayastillletter'F'inthedisplay*/
#include<pic.h>
#define_XTAL_FREQ20e6
__CONFIG(0x3F3A);
unsignedchari;
voidclock()
{
RB6=1;
RB6=0;
}
voidreset()
{
RB7=1;
RB7=0;
}
voiddisplay(unsignedcharc)
{
PORTD=c;/*todisplay1/5thofletter*/
__delay_ms(1);/*todisplaythedatainacolumnfor1ms*/
PORTD=255;/*toblankthedisplay*/
clock();/*togiveaclocktoCD4017forcolumnmultiplexing*/
}
voidpic_init()
{
TRISD=0;
TRISB6=0;
TRISB7=0;
}
/*MAINFUNCTION*/
voidmain()
{
__delay_ms(100);
pic_init();/*tosetoutports*/
while(1)
{
reset();/*tojumptofirstcolumnfromright*/
display(0x7f);/*1/5portionofletterF*/
display(0x6f);/*1/5portionofletterF*/

display(0x6f);/*1/5portionofletterF*/
display(0x6f);/*1/5portionofletterF*/
display(0x01);/*1/5portionofletterF*/
reset();/*tojumptofirstcolumnfromright*/
}
}
/*programend*/

Scrollingtextinthis10x8LEDdotmatrixdisplay:

Inthecaseofscrollingdisplayweneedtocreateabufferof10bytesandneedtostorethedatatobe
displayedinaframe.Thenafterdisplayingaframe,weneedtoshiftthedatawithinthearrayasshown
below.
?

1
2
3
4

for(i=9;i>0;i)
{
array[i]=array[i1];
}

Theabovecodeshiftthedatainthearraywhichistobedisplayedasnextshiftedframe.Now,array[0]
(thedatatobedisplayedinfirstcolumnfromtheright)isloadedwithnewdata,whichwillbeafraction
(1/5)ofa5x8font.Nowthenewframearrayisdisplayedforaparticularintervaloftime(depending
on
the
variable
speed
and
delays
used
in
the
program).
Brightness is equalized by activating the column LEDs one by one , using a scanning with in the
column.

1
2
3
4

for(j=0;j<9;j++)
{
PORTD=~(array[i]&(p));__delay_ms(.1);p<<=1;
}

/*Scrollingtextin10x8LEDdotmatrixdisplay*/
#include<pic.h>
#define_XTAL_FREQ20e6
__CONFIG(0x3F3A);
chararray[10],p,j,s,i,still;
voidclock(){RB6=1;RB6=0;}
voidreset(){RB7=1;RB7=0;}
voidscroll(chara,charb,charc,chard,chare)//displayfunction//
{
shortintcount=6;
while(count>0)
{
array[0]=~a;
a=b;b=c;c=d;d=e;e=255;
reset();
for(s=0;s<still;s++)
{
for(i=0;i<10;i++)
{
p=1;
for(j=0;j<9;j++)
{

PORTD=~(array[i]&(p));__delay_ms(.1);p<<=1;
}
clock();
}
}
for(i=9;i>0;i)
{
array[i]=array[i1];
}
count;
}
}
////////////////////////FONTDATA////////////////////////
voidA(){scroll(0xC1,0xB7,0x77,0xB7,0xC1);}//letterA
voidB(){scroll(0x01,0x6D,0x6D,0x6D,0x93);}//letterB
voidC(){scroll(0x83,0x7D,0x7D,0x7D,0xBB);}//"
voidD(){scroll(0x01,0x7D,0x7D,0xBB,0xC7);}
voidE(){scroll(0x01,0x6D,0x6D,0x6D,0x7D);}
voidF(){scroll(0x01,0x6F,0x6F,0x6F,0x7F);}
voidG(){scroll(0x83,0x7D,0x65,0x6D,0xA3);}
voidH(){scroll(0x01,0xEF,0xEF,0xEF,0x01);}
voidI(){scroll(0x7D,0x7D,0x1,0x7D,0x7D);}
voidJ(){scroll(0xF3,0x7D,0x7D,0x03,0x7F);}
voidK(){scroll(0x01,0xEF,0xD7,0xBB,0x7D);}
voidL(){scroll(0x01,0xFD,0xFD,0xFD,0xFD);}
voidM(){scroll(0x01,0xBF,0xDF,0xBF,0x01);}
voidN(){scroll(0x01,0xBF,0xDF,0xEF,0x01);}
voidO(){scroll(0x83,0x7D,0x7D,0x7D,0x83);}
voidP(){scroll(0x01,0x6F,0x6F,0x6F,0x9F);}
voidQ(){scroll(0x83,0x7D,0x75,0x79,0x81);}
voidR(){scroll(0x01,0x6F,0x6F,0x6F,0x91);}
voidS(){scroll(0x9B,0x6D,0x6D,0x6D,0xB3);}
voidT(){scroll(0x7F,0x7F,0x01,0x7F,0x7F);}
voidU(){scroll(0x03,0xFD,0xFD,0xFD,0x03);}
voidV(){scroll(0x07,0xFB,0xFD,0xFB,0x07);}
voidW(){scroll(0x01,0xFB,0xF7,0xFB,0x01);}
voidX(){scroll(0x39,0xD7,0xEF,0xD7,0x39);}
voidY(){scroll(0x3F,0xDF,0xE1,0xDF,0x3F);}
voidZ(){scroll(0x79,0x75,0x6D,0x5D,0x3D);}//letterZ
voidD0(){scroll(0x83,0x7D,0x7D,0x7D,0x83);}//NUM0
voidD1(){scroll(0xDD,0xBD,0x1,0xFD,0xFD);}
voidD2(){scroll(0xBD,0x79,0x75,0x6D,0x9D);}
voidD3(){scroll(0x7B,0x7D,0x5D,0x4D,0x33);}
voidD4(){scroll(0xCF,0xAF,0x6F,0xEF,0x1);}
voidD5(){scroll(0xB,0x5D,0x5D,0x5D,0x63);}
voidD6(){scroll(0x83,0x6D,0x6D,0x6D,0xB3);}
voidD7(){scroll(0x79,0x77,0x6F,0x5F,0x3F);}
voidD8(){scroll(0x93,0x6D,0x6D,0x6D,0x93);}
voidD9(){scroll(0x9B,0x6D,0x6D,0x6D,0x83);}//NUM9
voidSP(){scroll(255,255,255,255,255);}//SPACE
/////////////////////////////////////////
voidmain()
{
TRISD=0;
TRISB6=0;
TRISB7=0;
still=20;//SPEEDCONTROL

while(1)
{
A();B();C();D();E();F();G();H();I();J();
K();L();M();N();O();P();SP();SP();
/*etcetcetc*/
}
}
//PROGRAMEND//
Intheabovecode,wecanseethateachfontisafunction.Butthatisnotagoodway.Bettermethod
isalookuptableimplementationforthefontdatasothattheycouldbeeasilyfetchedwithoutanyif
elseconditionandthisdecreasetheaccesstimeandincreasetheefficiency..

////////////////////////////////////////////////////////////////////
/*Scrollingtextin10x8LEDdotmatrixdisplay*/
/*Improvedcodecomparedtopreviousone*/
/*Implementedalookuptableforfonttoincreasetheaccesstime*/
/*[email protected]://blog.vinu.co.in*/
////////////////////////////////////////////////////////////////////
#include<pic.h>
#define_XTAL_FREQ20e6
__CONFIG(0x3F3A);
chararray[10],p,j,s,i,still;
externconstcharfont_5x7[95][5];
voidclock(){RB6=1;RB6=0;}
voidreset(){RB7=1;RB7=0;}
voidscroll(chara,charb,charc,chard,chare)//displayfunction//
{
shortintcount=6;
while(count>0)
{
array[0]=a;
a=b;b=c;c=d;d=e;e=0;
reset();
for(s=0;s<still;s++)
{
for(i=0;i<10;i++)
{
p=1;
for(j=0;j<9;j++)
{
PORTD=~(array[i]&(p));__delay_ms(.1);p<<=1;
}
clock();
}
}
for(i=9;i>0;i)
{
array[i]=array[i1];
}
count;
}
}

voidprintf(constchar*p)
{
while(*p){
scroll(font_5x7[*p''][0],font_5x7[*p''][1],font_5x7[*p''][2],font_5x7[*p''][3],font_5x7[*p'
'][4]);
p++;
}
}
//SPACE
/////////////////////////////////////////
voidmain()
{
TRISD=0;
TRISB6=0;
TRISB7=0;
still=20;//SPEEDCONTROL
while(1)
{
printf("HELLOWORLD");
printf("Iamtestingfont..*!~_+=/\\,.7895WMvuy....");

}
}

//lookuptableforfont//
constcharfont_5x7[95][5]={
{0x00,0x00,0x00,0x00,0x00},//
{0x00,0x00,0x7a,0x00,0x00},//!
{0x00,0x70,0x00,0x70,0x00},//"
{0x14,0x3e,0x14,0x3e,0x14},//#
{0x10,0x2a,0x3e,0x2a,0x04},//$
{0x64,0x08,0x10,0x26,0x00},//%
{0x14,0x2a,0x14,0x02,0x00},//&
{0x00,0x00,0x70,0x00,0x00},//'
{0x00,0x3c,0x42,0x00,0x00},//(
{0x00,0x42,0x3c,0x00,0x00},//)
{0x00,0x2a,0x1c,0x2a,0x00},//*
{0x08,0x08,0x3e,0x08,0x08},//+
{0x00,0x01,0x06,0x04,0x00},//,
{0x08,0x08,0x08,0x08,0x00},//
{0x00,0x06,0x06,0x00,0x00},//.
{0x04,0x08,0x10,0x20,0x00},///
{0x00,0x3c,0x42,0x3c,0x00},//0
{0x00,0x22,0x7e,0x02,0x00},//1
{0x22,0x46,0x4a,0x32,0x00},//2
{0x44,0x52,0x52,0x6c,0x00},//3
{0x18,0x28,0x7e,0x08,0x00},//4
{0x74,0x52,0x52,0x4c,0x00},//5
{0x3c,0x52,0x52,0x0c,0x00},//6
{0x40,0x46,0x58,0x60,0x00},//7
{0x2c,0x52,0x52,0x2c,0x00},//8
{0x30,0x4a,0x4a,0x3c,0x00},//9
{0x00,0x36,0x36,0x00,0x00},//:
{0x01,0x36,0x34,0x00,0x00},//;
{0x00,0x08,0x14,0x22,0x00},//<
{0x14,0x14,0x14,0x14,0x00},//=
{0x00,0x22,0x14,0x08,0x00},//>

{0x00,0x20,0x4a,0x30,0x00},//?
{0x3c,0x42,0x5a,0x38,0x00},//@
{0x3e,0x48,0x48,0x3e,0x00},//A
{0x7e,0x52,0x52,0x2c,0x00},//B
{0x3c,0x42,0x42,0x24,0x00},//C
{0x7e,0x42,0x42,0x3c,0x00},//D
{0x7e,0x52,0x52,0x42,0x00},//E
{0x7e,0x50,0x50,0x40,0x00},//F
{0x3c,0x42,0x4a,0x2e,0x00},//G
{0x7e,0x10,0x10,0x7e,0x00},//H
{0x00,0x42,0x7e,0x42,0x00},//I
{0x04,0x02,0x02,0x7c,0x00},//J
{0x7e,0x18,0x24,0x42,0x00},//K
{0x7e,0x02,0x02,0x02,0x00},//L
{0x7e,0x30,0x30,0x7e,0x00},//M
{0x7e,0x30,0x0c,0x7e,0x00},//N
{0x3c,0x42,0x42,0x3c,0x00},//O
{0x7e,0x48,0x48,0x30,0x00},//P
{0x3c,0x46,0x42,0x3d,0x00},//Q
{0x7e,0x48,0x4c,0x32,0x00},//R
{0x24,0x52,0x4a,0x24,0x00},//S
{0x00,0x40,0x7e,0x40,0x00},//T
{0x7c,0x02,0x02,0x7c,0x00},//U
{0x78,0x06,0x06,0x78,0x00},//V
{0x7e,0x0c,0x0c,0x7e,0x00},//W
{0x66,0x18,0x18,0x66,0x00},//X
{0x00,0x70,0x0e,0x70,0x00},//Y
{0x46,0x4a,0x52,0x62,0x00},//Z
{0x00,0x7e,0x42,0x42,0x00},//[
{0x20,0x10,0x08,0x04,0x00},//"\"
{0x00,0x42,0x42,0x7e,0x00},//]
{0x00,0x20,0x40,0x20,0x00},//^
{0x02,0x02,0x02,0x02,0x00},//_
{0x00,0x40,0x20,0x00,0x00},//`
{0x0c,0x12,0x14,0x1e,0x00},//a
{0x7e,0x12,0x12,0x0c,0x00},//b
{0x0c,0x12,0x12,0x00,0x00},//c
{0x0c,0x12,0x12,0x7e,0x00},//d
{0x0c,0x16,0x1a,0x08,0x00},//e
{0x08,0x3e,0x48,0x20,0x00},//f
{0x0a,0x15,0x15,0x19,0x00},//g
{0x7e,0x10,0x10,0x0e,0x00},//h
{0x00,0x12,0x5e,0x02,0x00},//i
{0x00,0x02,0x01,0x5e,0x00},//j
{0x7e,0x08,0x14,0x02,0x00},//k
{0x00,0x42,0x7e,0x02,0x00},//l
{0x1e,0x08,0x18,0x0e,0x00},//m
{0x1e,0x10,0x10,0x0e,0x00},//n
{0x0c,0x12,0x12,0x0c,0x00},//o
{0x1f,0x12,0x12,0x0c,0x00},//p
{0x0c,0x12,0x12,0x1f,0x00},//q
{0x1e,0x10,0x10,0x08,0x00},//r
{0x0a,0x1a,0x16,0x14,0x00},//s
{0x10,0x7c,0x12,0x02,0x00},//t
{0x1c,0x02,0x02,0x1e,0x00},//u
{0x00,0x1c,0x02,0x1c,0x00},//v
{0x1e,0x06,0x06,0x1e,0x00},//w

{0x12,0x0c,0x0c,0x12,0x00},//x
{0x18,0x05,0x02,0x1c,0x00},//y
{0x12,0x16,0x1a,0x12,0x00},//z
{0x00,0x10,0x3c,0x42,0x00},//{
{0x00,0x00,0x7e,0x00,0x00},//|
{0x00,0x42,0x3c,0x10,0x00},//}
{0x20,0x40,0x20,0x40,0x00},//~
};

You might also like