找回密码
 注册会员
搜索附件  
MCU资讯论坛 附件中心 单片机论坛 51单片机论坛 仿真电路图.doc

仿真电路图.doc

 

c51驱动12864显示随机数proteus无法出结果!!:
初学单片机,想做个显示随机数的电路,但是怎么都无法出结果,程序通过编译了。。。。高手帮忙指点迷津啊!!谢谢啊~~~~
电路图: (图片可能显示不出来,电路图也上传了附件)
http://www.eehome.cn/file:///C:/Users/lzt/AppData/Local/Temp/msohtml1/01/clip_image002.jpg
程序:

#include<reg51.h>
#include<intrins.h>
#include<stdlib.h>
#define uchar unsigned char
#define uint unsigned int
/*端口定义*/
#define LCD_data P0
sbit LCD_RS = P3^5;
sbit LCD_RW = P3^6;
sbit LCD_EN = P3^4;
sbit LCD_PSB = P3^7;
sbit wela = P2^6;
sbit dula = P2^7;
uchar dis0[10];
uchar code dis1[]={"ww"};
uchar code dis2[]={"ww"};
uchar code dis3[]={"ww"};

void delay_1ms(uint x)
{
uint i,j;
for(j=0;j<x;j++)
for(i=0;i<110;i++);
}
/*写指令数据到LCD*/
void write_cmd(uchar cmd)
{
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
P0 = cmd;
delay_1ms(5);
LCD_EN = 1;
delay_1ms(5);
LCD_EN = 0;
}

/*写显示数据到LCD*/
void write_dat(uchar dat)
{
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 =dat;
delay_1ms(5);
LCD_EN = 1;
delay_1ms(5);
LCD_EN = 0;
}

/*设定显示位置*/
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if(X==0)
{X=0x80;}
else if (X==1)
{X=0x90;}
else if (X==2)
{X=0x88;}
else if (X==3)
{X=0x98;}
pos = X+Y;
write_cmd(pos);
}

void makerand()
{
uint ran;
ran=rand();
dis0[0]=ran/10000+0x30;
dis0[1]=ran%10000/1000+0x30;
dis0[2]=ran%1000/100+0x30;
dis0[3]=ran%100/10+0x30;
dis0[4]=ran%10+0x30;
ran=rand();
dis0[5]=ran/10000+0x30;
dis0[6]=ran%10000/1000+0x30;
dis0[7]=ran%1000/100+0x30;
dis0[8]=ran%100/10+0x30;
dis0[9]=ran%10+0x30;
}


/*LCD初始化设定*/
void lcd_init()
{
LCD_PSB = 1;
write_cmd(0x30);
delay_1ms(5);
write_cmd(0x0C);
delay_1ms(5);
write_cmd(0x01);
delay_1ms(5);
}

main()
{
uchar i;
wela=0;
dula=0;
delay_1ms(10); //延时
lcd_init(); //初始化LCD
lcd_pos(1,0); //设置显示位置为第二行的第一个字符
i=0;
while(dis1!='\0')
{
write_dat(dis1);
i++;
}
lcd_pos(2,0);
i=0;
while(dis2!='\0')
{
write_dat(dis2);
i++;
}
lcd_pos(3,0);
i=0;
while(dis3!='\0')
{
write_dat(dis3);
i++;
}
while(1)
{
lcd_pos(0,0);
makerand();
for(i=0;i<10;i++)
{
write_dat(dis0);
}
}
}


QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 06:25 , Processed in 0.046302 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

返回顶部