标题:
各位大师。。帮我看哈程序那里出错了。谢谢了。。
[打印本页]
作者:
张先生
时间:
2013-8-6 18:10
标题:
各位大师。。帮我看哈程序那里出错了。谢谢了。。
数码管位选码能不能用编码的形式表示,我这个程序很多错误,请大师指教。
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^7;
sbit dula=P2^6;
uchar a,b;
uchar code dulama[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f};//共阴数码管段选编码
uchar code welama[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf}//数码管的位选
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(a==20)
a=0;
for(b=0;b<10;b++)
{
wela=1;
P0=welama[b];
wela=0;
dula=1;
P0=dulama[b];
dula=0;
}
}
}
void To_time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
a++;
}
作者:
王少峰
时间:
2013-8-12 09:27
你这个连接几个数码管啊 ?还有段选和位选连到一个端口上了,P2^7这些引脚只能是高和低2种电平
作者:
xiao1074234390
时间:
2013-8-16 15:40
你位选和编码没错的话,这样看行不:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit wela=P2^7;
sbit dula=P2^6;
uchar a,b,c;
uchar code dulama[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f};//共阴数码管段选编码
uchar code welama[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf}//数码管的位选
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(a==20)
{
if(b==10)
b=0;
if(c==6)
c=0;
a=0;
wela=1;
P0=welama[c];
wela=0;
dula=1;
P0=dulama[b];
dula=0;
b++;
c++;
}
}
}
void To_time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
a++;
}
作者:
livingliving
时间:
2015-4-10 09:14
虽然不懂,但还是要顶,毕竟每一位老手都是从新手蜕变而来的,赞一个。。。。。。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1