请教各位达人.16*64点阵滚屏程序怎样写

请教各位达人.16*64点阵滚屏程序怎样写,第1张

#include<reg52.h>

#include<delay.h>//1MS延时

#define uchar unsigned char

#define uint unsigned int

#define hang P1 //行扫描接在P1口

sbit ds=P0^0

sbit clk=P0^1

sbit mr=P0^2

sbit g1=P0^3

sbit stcp=P0^4

uint counter

uchar flag

uchar code display[][32]={

/*-- 文字: 好 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,

0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,

/*-- 文字: 好 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,

0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,

/*-- 文字: 学 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0xE8,0x00,0x40,

0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x02,0x80,0x01,0x00,

/*-- 文字: 习 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x00,0x00,0x3F,0xFC,0x00,0x04,0x08,0x04,0x04,0x04,0x03,0x04,0x01,0x14,0x00,0x64,

0x01,0x84,0x06,0x04,0x38,0x04,0x10,0x04,0x00,0x04,0x00,0x24,0x00,0x14,0x00,0x00,

/*-- 文字: 天 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,

0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x0E,0xC0,0x04,

/*-- 文字: 天 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x00,0x08,0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,

0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x0E,0xC0,0x04,

/*-- 文字: 向 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x02,0x00,0x04,0x00,0x08,0x04,0x7F,0xFE,0x40,0x04,0x40,0x24,0x4F,0xF4,0x48,0x24,

0x48,0x24,0x48,0x24,0x48,0x24,0x4F,0xE4,0x48,0x24,0x40,0x04,0x40,0x14,0x40,0x08,

/*-- 文字: 上 --*/

/*-- 宋体12此字体下对应的点阵为:宽x高=16x16 --*/

0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x10,0x01,0xF8,0x01,0x00,0x01,0x00,

0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00}

void write_595(uchar shuju) //向595写一个字节的数据

{

uchar i

for(i=0i<8i++)

{

ds=(~shuju)&0x01

clk=1

clk=0

shuju=shuju>>1

}

}

void main() //主函数

{

uchar i,j,k

g1=0//154使能

EA=1//开总中断

TMOD=0x01//定时器0工作方式0

ET0=1//定时器0使能

TH0=(65535-50000)/256//定时器0设置初值

TL0=(65536-50000)%256

while(1)

{

for(i=0i<16i++) //字从下往上滚动出现

{

k=1

for(j=i+1j>0j--)

{

write_595(display[7][k])

write_595(display[7][k-1])

write_595(display[6][k])

write_595(display[6][k-1])

write_595(display[5][k])

write_595(display[5][k-1])

write_595(display[4][k])

write_595(display[4][k-1])

k+=2

hang=16-j

stcp=1stcp=0

}

delay_ms(20)

}

TR0=1flag=1

while(flag) //停留一秒

{

uchar j

for(j=0j<16j++)

{

write_595(display[7][j*2+1])

write_595(display[7][j*2])

write_595(display[6][j*2+1])

write_595(display[6][j*2])

write_595(display[5][j*2+1])

write_595(display[5][j*2])

write_595(display[4][j*2+1])

write_595(display[4][j*2])

hang=j

stcp=1stcp=0

}

}

TR0=0

for(i=16i>0i--) //字滚动出显示区

{

k=31

for(j=i-1j>0j--)

{

write_595(display[7][k])

write_595(display[7][k-1])

write_595(display[6][k])

write_595(display[6][k-1])

write_595(display[5][k])

write_595(display[5][k-1])

write_595(display[4][k])

write_595(display[4][k-1])

k-=2

hang=j

stcp=1stcp=0

}

delay_ms(20)

}

for(i=0i<16i++) //下四个字滚动出现在显示区

{

k=1

for(j=i+1j>0j--)

{

write_595(display[3][k])

write_595(display[3][k-1])

write_595(display[2][k])

write_595(display[2][k-1])

write_595(display[1][k])

write_595(display[1][k-1])

write_595(display[0][k])

write_595(display[0][k-1])

k+=2

hang=16-j

stcp=1stcp=0

}

delay_ms(20)

}

TR0=1flag=1

while(flag) //停留一秒

{

uchar j

for(j=0j<16j++)

{

write_595(display[3][j*2+1])

write_595(display[3][j*2])

write_595(display[2][j*2+1])

write_595(display[2][j*2])

write_595(display[1][j*2+1])

write_595(display[1][j*2])

write_595(display[0][j*2+1])

write_595(display[0][j*2])

hang=j

stcp=1stcp=0

}

}

TR0=0

for(i=16i>0i--) //滚出显示区

{

k=31

for(j=i-1j>0j--)

{

write_595(display[3][k])

write_595(display[3][k-1])

write_595(display[2][k])

write_595(display[2][k-1])

write_595(display[1][k])

write_595(display[1][k-1])

write_595(display[0][k])

write_595(display[0][k-1])

k-=2

hang=j

stcp=1stcp=0

}

delay_ms(20)

}

}

void timer0() interrupt 1 //中断函数

{

counter++

if(counter==20) //1秒设置

{

counter=0

flag=0

}

TH0=(65535-50000)/256

TL0=(65536-50000)%256

}

这是16X16的,自己一改就好了

//74HC595练习程序

//串入并出实现16流水灯效果

//2009.12.28

#include"reg52.h"

sbit shcp=P2^0 //数据在上升沿进入移位寄存器

sbit date1=P2^1 //串行数据输入端

sbit clock=P2^2 //上升沿时将数据输出到并行端口

unsigned char tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}

unsigned char tab1[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}

void delay(unsigned int delay)

{

unsigned char i

for(delay>0delay--)

for(i=0i<125i++)

}

void send_data(unsigned char date) //发送数据

{

unsigned char i

for(i=0i<8i++) //把每一位数据移入寄存器

{

shcp=0

date=date<<1

date1=CY

shcp=1

delay(20)

}

}

void main()

{

unsigned char k

for(k=0k<16k++)

{

send_data(tab[k])

send_data(tab1[k])

{clock=0clock=1}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11103018.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存