用74HC595驱动16×16点阵显示中文 C语言程序和仿真 谢谢!!!
这个图片会压小。看大图到这看
http://0e.images22.51img1.com/6000/kgd235143/e4be871c454f0c1d6f7f46b964dacee7.jpg
要仿真的话我发给你,当然实际电路要三极管驱动
#include <reg52.h>
#define uchar unsigned char
uchar i,j,k=15;
sbit xsi=P2^0;
sbit xrck=P2^1;
sbit xsck=P2^2;
sbit ysi=P2^3;
sbit yrck=P2^4;
sbit ysck=P2^5;
sbit kg= P3^2;
uchar code zbm[][32]={
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},
{0xFF,0xFF,0xFF,0xF7,0xBF,0xF7,0xBF,0xFB,0xBF,0xFD,0x03,0xE0,0xFF,0xFF,0xFF,0xFF,
0x01,0xF0,0x7F,0xEF,0xBF,0xEF,0x9F,0xEF,0xDF,0xEF,0xFF,0xF1,0xFF,0xFF,0xFF,0xFF},/*"北",0*/
{0xF7,0xFF,0xF7,0xFF,0xF7,0xEF,0xF7,0xF3,0x37,0xFF,0xB7,0xFE,0xB6,0xDE,0xD5,0x80,
0xDB,0xFE,0x5B,0xFF,0x9B,0xFB,0xFB,0xF7,0xFB,0xE7,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF},/*"京",1*/
{0xFF,0xEF,0x5F,0xF7,0xDF,0xFA,0xEF,0xFD,0x0F,0xFA,0xFF,0xDF,0xBF,0xEF,0xC7,0xF3,
0x58,0xFC,0xEF,0xFB,0xAF,0xF7,0xCF,0xEF,0xEF,0xCF,0xFF,0xDF,0xFF,0xDF,0xFF,0xFF},/*"欢",2*/
{0xBF,0xF7,0xBF,0xF7,0xBB,0xF6,0x37,0xF1,0xFF,0xF7,0x07,0xF6,0xF7,0xF6,0x7B,0xF7,
0xF9,0xE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,0xBB,0xFD,0xBB,0xFD,0xBF,0xFD,0xFF,0xFD,0xFF,0xFD,0xFF,0xFF},/*"阵",4*/
{0xFF,0xEF,0xFF,0xF7,0xFF,0xF9,0x7F,0xFE,0x81,0xBD,0x75,0xDD,0x65,0xE5,0x55,0xF8},
{0xB6,0xFD,0x9A,0xFD,0x28,0x80,0xBC,0xFE,0xBF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFF},/*"屏",5*/
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,},
};
void ys (uchar a) //延时
{
uchar b;
for (;a>0;a--)
for (b=100;b>0;b--) ;
}
void yfs() //Y轴发数
{
ysck=0;
yrck=0;
k++;
if (k==16)
{
k=0;
ysi=0;
}
else
ysi=1;
ysck=1;
P2=P2|0X14;
//相当于 xrck=1; yrck=1;
}
void xfs(uchar a) //X轴发数
{
uchar b,a1,a2;
a1=~zbm[6][a*2+1];
a2=~zbm[6][a*2];
xsck=0;
xrck=0;
for (b=0;b<8;b++)
{
a1=a1<<1;
xsi=CY;
xsck=1;
xsck=0;
}
for (b=0;b<8;b++)
{
a2=a2<<1;
xsi=CY;
xsck=1;
xsck=0;
}
}
void fs(uchar a) //X轴发数
{
uchar b;
xsck=0;
xrck=0;
for (b=0;b<8;b++)
{
a=a<<1;
xsi=CY;
xsck=1;
xsck=0;
}
}
void gdhs(uchar *zz,uchar N,uchar Time) //流动显示N个汉字 滚动函数
{ //参数三个:字符串字模首地址、字数、显示流动速度
uchar FontNum,i,j,row; //循环变量,字数计数、16次流动、16列扫描
for(FontNum=0;FontNum<N;FontNum++)
{
for(i=0;i<16;i++) //字到字流动 16次左移才能完成
{
for(j=0;j<Time;j++) //显示延迟,决定流动速度
{
k=15;
for(row=0;row<16;row++) //显示16*16屏幕一次
{
yfs(); //选通显示列 //行选线,P3 低四位
fs (~*(zz+FontNum*32+(i+row)*2+1)); //以移动偏移为基础获取新数据
fs(~*(zz+FontNum*32+(i+row)*2)); //获取显示数据 循环显示关键算法
ys (12); //适当延时
}
}
}
}
}
void wbzd () interrupt 0 //外部中断
{
j++;
if (j>1)
j=0;
ys(10);
while (!kg)
{
k=15;
for (i=0;i<16;i++)
{
yfs();
xfs(i);
ys(10);
}
}
if (j==0)
gdhs(zbm,8,2);
if (j==1)
gdhs(zbm1,10,1);
}
void main ()
{
EA = 1; //打开总中断
EX0=1;
IT0=1;
while (1)
{
if (j==0)
gdhs(zbm,8,5);
if (j==1)
gdhs(zbm1,10,3);
}
}
2023-06-12 广告
16*128 LED点阵屏 C 程序
******************************************************
声明:
本程序供大家学习之用,用勿用于商业用途。尊重版权。
编写:邓椿薪
时间:2006年1月20日 晚
邮箱:love2151@xinhuanet.com
*******************************************************
//595连级输出数据,138行驱动。P0_1为移动速度高速/*点阵显示汉字程串口输出字符数据,
//P2口输出行扫描信号,P2_7输出595锁存信号。*/
#define uchar unsigned char
#define uint unsigned int
#include <REG51.H>
#include <CODESUB.H>
uchar yid,h,d=12; //YID为移动计数器,H为行段计数器。
uint zimuo,zimuo1; //字模计数器
uchar BUFF[18]; //缓存
void in_data(void); //调整数据
void rxd_data(void); //发送数据
void in_data1(char h);
void rxd_data1(void);
void sbuf_out1(void);
void sendsw(uchar k); //发送段代码
void sbuf_out(void); //16段扫描
void key(void);
sbit AN1=P3^4;
sbit AN2=P3^5;
sbit clk=P3^3;
unsigned code sw[16]={0x7f,0x6f,0x5f,0x4f,0x3f,0x2f,0x1f,0x0f,0xf7,
0xf6,0xf5,0xf4,0xf3,0xf2,0xf1,0xf0}; /*16行段码*/
/********************************************/
void main(void)
{ uchar i;
zimuo1=sizeof(hanzi)-6*32;//(zishu+9)*32;
yid=0;
zimuo=0;
while(1)
{
while(yid<100) //数据移位。
{
for(i=0;i<D;I++) if(zimuo 后移一个字, zimuo="zimuo+32*5;//zimuo+32;" yid="0;" } 移动一步 yid++; sbuf_out1();key(); { 移动速度>zimuo1) //总数减7个字。
zimuo=0;
}
}
void sbuf_out1()
{
char i;
for(h=0;h<32;h++)
{
in_data1(h);
clk=1;
rxd_data1();
if(h>=16)
else i=h;
sendsw(sw[i]);
}
}
/******************************************************/
void in_data1(char h)
{
char s,i;
if(h>=16)
{i=(h-16);
for(s=5;s>=0;s--) //h为向后先择字节计数器,zimuoo为向后先字计数器
{
// if(zimuo%32)
BUFF[2*s+1]=hanzi[zimuo+1+32*s+2*i]; //把第一个字模的第一个字节放入BUFF1中,第二个字模和第一个字节放入BUFF3中
BUFF[2*s]=hanzi[zimuo+0+32*s+2*i]; // 把第一个字模的第二个字节放入BUFF0中,第二个字模的第二个字节放入BUFF1中
}
}
else
{
i=h;
for(s=5;s>=0;s--) //h为向后先择字节计数器,zimuoo为向后先字计数器
{
// if(zimuo%32)
BUFF[2*s+1]=hanzi[zimuo+1+32*s+2*i]; //把第一个字模的第一个字节放入BUFF1中,第二个字模和第一个字节放入BUFF3中
BUFF[2*s]=hanzi[zimuo+0+32*s+2*i]; // 把第一个字模的第二个字节放入BUFF0中,第二个字模的第二个字节放入BUFF1中
}
}
}
/*******************************************************/
void rxd_data1(void) //串行发送数据
{
char s;
for(s=0;s<10;s++) //发送5字节数据
{
SBUF=255-BUFF[s];//把BUFF中的字节从大到小移位相或后发送输出。
while(!TI);TI=0; //等待发送中断
}
}
void sendsw(uchar k)
{
TI=0;
SBUF=k;
while(!TI);TI=0;
clk=0;
}
void key(void)
{
uchar a,b;
if(AN1==0)
{
for(a=0;a<10;a++)
}
if(AN1==0)
{while(AN1==0)
{}
if(AN1)
{d++;
if(d>100)
d=100;
}
}
}
if(AN2==0)
{for(a=0;a<10;a++)
}
if(AN2==0)
{while(AN2==0)
{}
if(AN2)
{d--;
if(d==0)
d=1;
}
}
}
}
不是我写的,但我想会对你有用。
#include < intrins.h >
#define uchar unsigned char
#define uint unsigned int
sbit clk=P0^5; //595移位时钟,上升沿触发
sbit rclk=P0^4; //595数据锁存信号,上升沿触发
sbit red=P0^6; //红色移位数据输入
sbit green =P0^7; //绿色移位数据输入
sbit OE=P2^7; //行扫描使能端,高电平有效
uchar wei; //左移一位记录
uint word; //显示字记录
uchar hang; //行扫描
uchar sec50; //左移时间
uchar speed; //速度值
void delay()
{
uchar q;
for(q=0;q<255;q++);
}
uchar code hanzi[][32]={
{0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02},/*"我",0*/
{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},/*"好",1*/
{0x10,0x00,0x10,0xFC,0x10,0x84,0xFE,0xFC,0x38,0x84,0x34,0xFC,0x54,0x84,0x50,0x84,0x90,0xFC,0x00,0x00,0x01,0x00,0x08,0x84,0x28,0x82,0x28,0x12,0x67,0xF0,0x00,0x00},/*"想",2*/
{0x00,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x00,0x00,0xFF,0xFE,0x01,0x00,0x09,0x00,0x09,0xF8,0x09,0x00,0x15,0x00,0x23,0x00,0x40,0xFE,0x00,0x00},/*"是",3*/
{0x00,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x02,0x80,0x04,0x60,0x18,0x18,0x60,0x08,0x00,0x00},/*"贝",4*/
{0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x3F,0xF0,0x00,0x00,0x3F,0xFE,0x40,0x04,0x80,0x08,0x0F,0xC0,0x08,0x40,0x08,0x40,0x08,0x44,0x10,0x44,0x60,0x3C,0x00,0x00},/*"壳",5*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x10,0x00,0x20,0x00,0x00,0x00},/*",",6*/
{0x10,0x40,0xFE,0x40,0x10,0x78,0x7C,0x90,0x10,0x20,0xFE,0xFC,0x00,0x24,0x7D,0xFE,0x44,0x24,0x7C,0xFC,0x44,0x20,0x7C,0x20,0x44,0x20,0x44,0x20,0x54,0xA0,0x48,0x40},/*"静",7*/
{0x10,0x40,0xFE,0x40,0x10,0x78,0x7C,0x90,0x10,0x20,0xFE,0xFC,0x00,0x24,0x7D,0xFE,0x44,0x24,0x7C,0xFC,0x44,0x20,0x7C,0x20,0x44,0x20,0x44,0x20,0x54,0xA0,0x48,0x40},/*"静",8*/
{0x00,0x20,0x11,0x20,0x11,0x20,0x11,0x24,0xFD,0x3E,0x11,0xE4,0x17,0x24,0x11,0x24,0x11,0x24,0x11,0x34,0x11,0x28,0x1D,0x20,0x31,0x02,0xC1,0x02,0x00,0xFE,0x00,0x00},/*"地",9*/
{0x04,0x40,0xFF,0xFE,0x04,0x50,0x04,0x28,0x1F,0xFE,0x50,0x20,0x57,0xA8,0x75,0x2C,0x17,0xA8,0x74,0xA8,0x57,0x90,0x55,0x10,0x97,0xAA,0x20,0x4A,0x20,0x84,0x40,0x00},/*"藏",10*/
{0x02,0x00,0x02,0x00,0x7F,0xFE,0x04,0x00,0x04,0x00,0x08,0x40,0x18,0x40,0x17,0xFC,0x30,0x40,0x50,0x40,0x90,0x40,0x10,0x40,0x10,0x40,0x17,0xFE,0x10,0x00,0x00,0x00},/*"在",11*/
{0x20,0x40,0x10,0x40,0x10,0x40,0x01,0x50,0x41,0x48,0x2A,0x44,0x0A,0x42,0x14,0x40,0x10,0x44,0x20,0x44,0xE0,0x08,0x20,0x10,0x20,0x20,0x20,0xC0,0x23,0x00,0x2C,0x00},/*"沙",12*/
{0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00},/*"子",13*/
{0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x01,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00},/*"里",14*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x10,0x00,0x20,0x00,0x00,0x00},/*",",15*/
{0x20,0x80,0x3E,0xFC,0x28,0xA0,0x45,0x10,0x85,0x10,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x20,0x00,0x20,0x7F,0xFC,0x04,0x20,0x02,0x20,0x02,0x20,0x00,0xA0,0x00,0x40},/*"等",16*/
{0x10,0x40,0x18,0x40,0x13,0xFC,0x28,0x40,0x4C,0x40,0x88,0x40,0x17,0xFE,0x10,0x10,0x30,0x10,0x57,0xFE,0x10,0x10,0x11,0x10,0x11,0x10,0x10,0x10,0x10,0x50,0x10,0x20},/*"待",17*/
{0x20,0x20,0x10,0x20,0x10,0x20,0xFF,0xFE,0x0A,0x24,0x0A,0x20,0x12,0xF8,0x36,0x88,0x5A,0x88,0x96,0x50,0x12,0x50,0x12,0x20,0x12,0x50,0x12,0x48,0x12,0x86,0x15,0x04},/*"被",18*/
{0x10,0x00,0x10,0x40,0x10,0x40,0xFC,0xA0,0x11,0x10,0x13,0xE8,0x14,0x06,0x18,0x00,0x30,0x84,0xD2,0x44,0x11,0x48,0x11,0x10,0x10,0x20,0x17,0xFE,0x50,0x00,0x20,0x00},/*"捡",19*/
{0x08,0x00,0x08,0x00,0x08,0xF8,0x7E,0x08,0x08,0x08,0x08,0x08,0xFE,0xF8,0x08,0x80,0x48,0x80,0x4E,0x84,0x48,0x84,0x48,0x7C,0x48,0x00,0xA8,0x00,0x9F,0xFE,0x00,0x00},/*"起",20*/
{0x10,0x80,0x10,0x80,0x20,0x80,0x7C,0xFC,0x45,0x04,0x45,0x04,0x46,0x04,0x7C,0x84,0x44,0x44,0x44,0x64,0x44,0x24,0x44,0x04,0x7C,0x04,0x44,0x28,0x40,0x10,0x00,0x00},/*"的",0*/
{0x00,0x00,0x7E,0x7E,0x12,0x44,0x12,0x48,0x7E,0x48,0x12,0x50,0x12,0x48,0x7E,0x44,0x12,0x42,0x12,0x42,0x22,0x52,0x22,0x4C,0x42,0x40,0x8A,0x40,0x04,0x40,0x00,0x40},/*"那",21*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"一",22*/
{0x08,0x04,0x06,0x04,0x04,0x04,0x7F,0xA4,0x10,0x24,0x22,0x24,0x7F,0x24,0x26,0x24,0x0C,0xA4,0x19,0xE4,0x33,0x24,0xC6,0x04,0x09,0x04,0x31,0x84,0xC1,0x14,0x00,0x08},/*"刻",23*/
{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,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
};
void senddata(uchar datat)//发送子程序
{
uchar k;
for(k=0;k<8;k++)
{
clk=0;
red=(datat&0x80);
green=(datat&0x80);
datat<<=1;
clk=1;
}
}
void sendwei(void)
{
uchar i,j;
uchar huancun1,huancun2;
bit bdata l=0;
huancun1=hanzi[word][hang*2];
huancun2=hanzi[word][hang*2+1];
j=wei;
if(j>=7)
{
senddata(huancun1);
j=j-7;
l=1;
}
for(i=0;i<j;i++)
{
if(l==1)
{
red=(huancun2&0x80);
green=(huancun2&0x80);
clk=0;
huancun2<<=1;
clk=1;
}
else
{
red=(huancun1&0x80);
green=(huancun1&0x80);
clk=0;
huancun1<<=1;
clk=1;
}
}
}
void sendhang(void)
{
delay();
OE=0;
P0&=0xf0;
P0|=hang;
}
void clearpingandinit(void)
{
uchar j,k;
P0=0x00;
hang=0x00;
word=0x00;
wei=0x00;
sec50=0x00;
speed=0x0f;
for(k=0;k<8;k++)
{
for(j=0;j<8;j++)
{red=0;green=0;
clk=0;
clk=1;}
}
rclk=0;
rclk=1;
TMOD=0x11;
TCON=0x00;
IE=0x8A;
IP=0x08;
TH0=0xF5;
TL0=0x16;
TH1=0xfa;
TL1=0x98;
}
void timer0() interrupt 1
{
uchar n,m;
OE=0;
TH0=0xff;
TL0=0x00;
if(word<=4)
{
for(n=5-word;n>0;n--)
{
senddata(0x00);
senddata(0x00);
}
}
if(word<=4)
m=0x00;
else
m=word-5;
for(n=m;n<word;n++)
{
senddata(hanzi[n][hang*2]);
senddata(hanzi[n][hang*2+1]);
}
sendwei();
sendhang();
rclk=0;
OE=0;
hang++;
if(hang>=16)
{
hang=0;
}
rclk=1;
}
void timer1() interrupt 3//定时器1中断入口,这里是制位速度
{
TH1=0xfa;
TL1=0x98;
sec50++;
if(sec50==speed)
{
sec50=0x00;
wei++;
if(wei>=16)
{
wei=0;
word++;
if(word==29)
{
word=0;
}
}
}
}
void clearsuocun(void)
{
uchar i,j;
clk=1;
rclk=1;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
green=0;
red=0;
clk=0;
clk=1;
}
}
rclk=0;
rclk=1;
}
void main(void)
{
clearpingandinit();
TR0=1;
TR1=1;
while(1)
{
EA=1;
clearsuocun();
EA=0;
}
}