您的位置 首页 测评

PIC16F877A单片机对24X24点点阵屏的驱动规划

PIC16F877A单片机对24X24点点阵屏的驱动设计-1.本实例采用微芯PIC16F877A单片机,此单片机适合初学者

2.点阵采用24X24点,左边为行线,采用U1-U3三个74LS373地址所存芯片,复用单片机RB端口。

右边为列线,采用U4-U6三个74LS373地址所存芯片,复用单片机RD端口。

3.单片机RC端口控制六片373的选通。

4.显示原理:24列列线轮流拉为低电平时,行线输出行玛,通过一定延时,字符即可显示,并通过计算,即可实现上述四种显示方式。

最近总算有空更新了,花了几天时刻,弄出个小东西,尽管有很多种完成方法在网上撒播了,但我却从没有试过,乘有时刻,也弄出了四种方法的显现,各位帮助看看,哪里还有欠好的当地,希不吝珠玉。

一。原理及仿真图

P%&&&&&%16F877A单片机对24X24点点阵屏的驱动规划

此种为从右往左显现。

P%&&&&&%16F877A单片机对24X24点点阵屏的驱动规划

此中为从左往右显现

P%&&&&&%16F877A单片机对24X24点点阵屏的驱动规划

此种为从下往上显现

P%&&&&&%16F877A单片机对24X24点点阵屏的驱动规划

此种为从上往下显现

原理图阐明:

1.本实例选用微芯PIC16F877A单片机,此单片机合适初学者

2.点阵选用24X24点,左面为行线,选用U1-U3三个74LS373地址所存芯片,复用单片机RB端口。

右边为列线,选用U4-U6三个74LS373地址所存芯片,复用单片机RD端口。

3.单片机RC端口操控六片373的选通。

4.显现原理:24列列线轮番拉为低电平时,行线输出行玛,经过必定延时,字符即可显现,并经过核算,即可完成上述四种显现方法。

二。程序(已附解说,PICC 8.05 经过)

#include

#define uch unsigned char

int offset;//界说偏置变量,以使字符运动

//以下为需显现的字符数组

const uch zxhn[]=

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x10,0x30,0xE0,0x60,0x00,0x80,0x00,0xF0,0xF0,0x10,0x00,0xF0,0xE0,

0x20,0x00,0x00,0xF0,0xF0,0x10,0x00,0x00,0x00,0x81,0x83,0x8E,0xCE,0xE0,0x78,0x76,

0x3D,0x00,0xFF,0x7F,0x04,0x38,0xFF,0xFF,0x00,0x3C,0x38,0xFF,0xFF,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x3F,0x3F,0x20,0x10,0x18,0x0E,0x07,0x00,0x00,0x00,0x1F,0x1F,

0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,//“洲”,

0x00,0x00,0x00,0x30,0x60,0x00,0x80,0x70,0x30,0x90,0x40,0x40,0x40,0x40,0xE0,0xE0,

0x40,0x40,0x40,0x40,0xE0,0xE0,0x40,0x00,0x00,0x41,0x49,0x49,0x49,0xFF,0xFF,0x49,

0x6D,0x6D,0x4B,0x9C,0x8C,0x40,0xFF,0xFF,0x01,0x8E,0x8C,0x40,0xFF,0xFF,0x00,0x00,

0x00,0x40,0x20,0x10,0x0C,0x07,0x01,0x00,0x00,0x03,0x03,0x11,0x10,0x30,0x3F,0x1F,

0x11,0x11,0x10,0x70,0x3F,0x3F,0x00,0x00,//“翔”

0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xC0,0x80,0x00,0x00,0xE0,0xF8,0x38,

0x10,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x02,0x04,0x18,0xB0,0xE0,0xFC,

0x9F,0x23,0x10,0x0C,0x07,0xC3,0xFD,0x3D,0x3D,0xE5,0x19,0x07,0x03,0x03,0x01,0x00,

0x00,0x10,0x08,0x04,0x03,0x41,0x20,0x21,0x27,0x1F,0x18,0x0C,0x06,0x03,0x01,0x00,

0x00,0x03,0x0F,0x1C,0x38,0x18,0x10,0x10,//“欢”

0x00,0x00,0x00,0x10,0x30,0xE0,0xC0,0x00,0x00,0xC0,0xC0,0x20,0x30,0x38,0x10,0xF0,

0xC0,0x40,0x40,0x40,0xE0,0xC0,0x40,0x00,0x00,0x00,0x08,0x08,0x08,0xFC,0xFC,0x08,

0x80,0xFF,0xFF,0x40,0x20,0x20,0x00,0xFF,0xFF,0x40,0x80,0x80,0xFF,0xFF,0x00,0x00,

0x00,0x00,0x18,0x18,0x0C,0x07,0x07,0x0C,0x08,0x18,0x10,0x10,0x30,0x30,0x30,0x37,

0x37,0x30,0x30,0x31,0x30,0x30,0x10,0x08,//“迎”

0x00,0x00,0x00,0x00,0x80,0xC0,0x70,0x30,0x10,0x00,0x00,0xC0,0x70,0x78,0x50,0x40,

0x40,0x40,0x40,0xC0,0xE0,0x40,0x40,0x00,0x00,0x08,0x04,0x02,0x03,0xFF,0x7F,0x00,

0x40,0x22,0x11,0x9C,0x0E,0x44,0xC0,0xFF,0x7F,0x01,0x06,0x09,0x38,0x70,0x00,0x00,

0x00,0x00,0x10,0x30,0x3C,0x1F,0x00,0x1F,0x3F,0x31,0x30,0x30,0x37,0x37,0x30,0x38,

0x3E,0x18,0x01,0x02,0x0E,0x1C,0x18,0x00, //“您”

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

const uch col[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//列码

//初始化子程序

void init()

{

ADCON1=0x06;//初始化RA口为一般数字端口

TRISA=0X20;

PORTA=0;

TRISB=0;

PORTB=0;

TRISC=0;

PORTC=0;

TRISD=0;

PORTD=0;

}

//延时子程序

void delay1ms()

{

uch i;

for(i=0;i《150;i++)

{NOP();

}

}

//从右往左显现

void display1()

{

uch i,j,k,t,n;

int m=0;//字符定位变量

for(n=0;n《6;n++)

{

for(offset=0;offset《24;offset++)//偏置最多24位

{

for(t=0;t《4;t++)//每个方位显现4次

{

for(i=0;i《24;i++)//取数,每行24列,故取24个数

{

PORTD=0xff;//一开始先把列置高电平,关显现

PORTC=0x70;

NOP();

PORTC=0;

PORTB=zxhn[i+offset+m];//取行码

if((i+offset)》23)PORTB=zxhn[i+offset+48+m];

RC0=1;

NOP();

RC0=0;

PORTB=zxhn[i+24+offset+m];

if((i+offset)》23)PORTB=zxhn[i+offset+72+m];

RC1=1;

NOP();

RC1=0;

PORTB=zxhn[i+48+offset+m];

if((i+offset)》23)PORTB=zxhn[i+offset+96+m];

RC2=1;

NOP();

RC2=0;

j=i/8;//求需求选通的行线

k=i%8;//求需求选通的列线

PORTD=col[k];

switch(j)

{

case 0: RC4=1; NOP(); RC4=0; break;

case 1: RC5=1; NOP(); RC5=0; break;

case 2: RC6=1; NOP(); RC6=0; break;

}

delay1ms();//视觉暂留

}

}

}

m=m+72;//定位下一个初始字符

}

}

//从左往右显现

void display2()

{

uch i,j,k,t,n,tt1,tt2,tt3;

int m=0;//字符定位变量

for(n=0;n《6;n++)

{

for(offset=24;offset》0;offset–)//偏置最多24位

{

for(t=0;t《4;t++)//每个方位显现4次

{

for(i=24;i》0;i–)//取数,每行24列,故取24个数

{

if((i+offset)》23)

{

tt1=zxhn[i+offset-24+m];

tt2=zxhn[i+offset+m];

tt3=zxhn[i+offset+24+m];

}

else

{

tt1=zxhn[i+offset+m+72];

tt2=zxhn[i+offset+m+96];

tt3=zxhn[i+120+offset+m];

}

PORTD=0xff;//一开始先把列置高电平,关显现

PORTC=0x70;

NOP();

PORTC=0;

PORTB=tt1;//取行码

RC0=1;

NOP();

RC0=0;

PORTB=tt2;

RC1=1;

NOP();

RC1=0;

PORTB=tt3;

RC2=1;

NOP();

RC2=0;

j=(i-1)/8;//求需求选通的373

k=(i-1)%8;//求需求选通的列线

PORTD=col[k];

switch(j)

{

case 0: RC4=1; NOP(); RC4=0; break;

case 1: RC5=1; NOP(); RC5=0; break;

case 2: RC6=1; NOP(); RC6=0; break;

}

delay1ms();//视觉暂留

}

}

}

m=m+72;

}

}

//从下往上显现

void display3()

{

uch i,j,k,t,n,tt1,tt2,tt3,l;

int m=0;//字符定位变量

for(n=0;n《18;n++)

{

for(l=0;l《7;l++)//翻滚8位

{

for(t=0;t《3;t++)//每个方位显现4次

{

for(i=0;i《24;i++)//取数,每行24列,故取24个数

{

tt1=(zxhn[i+m]》》l)|(zxhn[i+24+m]《《(8-l));

tt2=(zxhn[i+24+m]》》l)|(zxhn[i+48+m]《《(8-l));

tt3=(zxhn[i+48+m]》》l)|(zxhn[i+72+m]《《(8-l));

PORTD=0xff;//一开始先把列置高电平,关显现

PORTC=0x70;

NOP();

PORTC=0;

PORTB=tt1;//取行码

RC0=1;

NOP();

RC0=0;

PORTB=tt2;

RC1=1;

NOP();

RC1=0;

PORTB=tt3;

RC2=1;

NOP();

RC2=0;

j=i/8;//求需求选通的373

k=i%8;//求需求选通的列线

PORTD=col[k];

switch(j)

{

case 0: RC4=1; NOP(); RC4=0; break;

case 1: RC5=1; NOP(); RC5=0; break;

case 2: RC6=1; NOP(); RC6=0; break;

}

delay1ms();//视觉暂留

}

}

}

m=m+24;

}

}

//从上往下显现

void display4()

{

uch i,j,k,t,n,tt1,tt2,tt3,l,a,b;

int m=0;//字符定位变量

for(n=0;n《6;n++)

{

for(l=0;l《24;l++)

{

for(t=0;t《3;t++)//每个方位显现4次

{

for(i=0;i《24;i++)//取数,每行24列,故取24个数

{

a=l/8;

b=l%8;

if(a==0)

{

tt1=(zxhn[i+m]《》(8-b));

tt2=(zxhn[i+24+m]《》(8-b));

tt3=(zxhn[i+48+m]《》(8-b));

}

if(a==1)

{

tt1=(zxhn[i+m+120]《》(8-b));

tt2=(zxhn[i+m]《》(8-b));

tt3=(zxhn[i+24+m]《》(8-b));

}

if(a==2)

{

tt1=(zxhn[i+m+96]《》(8-b));

tt2=(zxhn[i+m+120]《》(8-b));

tt3=(zxhn[i+m]《》(8-b));

}

PORTD=0xff;//一开始先把列置高电平,关显现

PORTC=0x70;

NOP();

PORTC=0;

PORTB=tt1;//取行码

RC0=1;

NOP();

RC0=0;

PORTB=tt2;

RC1=1;

NOP();

RC1=0;

PORTB=tt3;

RC2=1;

NOP();

RC2=0;

j=i/8;//求需求选通的行线

k=i%8;//求需求选通的列线

PORTD=col[k];

switch(j)

{

case 0: RC4=1; NOP(); RC4=0; break;

case 1: RC5=1; NOP(); RC5=0; break;

case 2: RC6=1; NOP(); RC6=0; break;

}

delay1ms();//视觉暂留

}

}

}

m=m+72;

}

}

void main()

{

uch mo;

init();

while(1)

{

display1();

display2();

display3();

display4();

}

}

三。总结

尽管已有四种方法显现了,但我觉得能够测验更多的方法,例如,能够象滚轮子相同,旋转着从左滚到右显现,仅仅数据处理的量或许大了些,已经有两个自在度了,而我的四种只要一个自在度。因为自己水平有限,没有想到什么好的思路,不过期望抛砖引玉,写出这种显现方法。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ceping/344709.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部