我想让数码管扫描显示,第一个显示1第二个是2,依次类推,但是程序仿真就是不对
#include<reg52.h> #define uchar unsigned char #define uint unsigned int //uchar duan,wei;sbit duan=P1^6;sbit wei=P1^7; uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; void delay(uint z) { uint x,y; for(x<z;x>0;x--) for(y<100;y>0;y--);
} void main() { uint i,j; while(1) { wei=1; for(j=0;j<8;j++) { P2=table1[j]; wei=0; } duan=1; for(i=0;i<16;i++) { P2=table[i]; delay(20); duan=0; } } }
怎么写呢,写完我追分
追答#include //52系列单片机头文件
#define uchar unsigned char //宏定义
#define uint unsigned int
sbit dula=P2^6; //申明u1锁存器的锁存端
sbit wela=P2^7; // u2
uchar num1,num2;
uchar code table[]={ //数组定义
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar code aable[]={ //位选数组定义
0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
void delays(uint); //子函数申明
void main()
{
while(1)
{
for(num1=0;num10;i--)
for(j=1000;j>0;j--)
for(k=110;k>0;k--);
}
/*----------------延时程序-----------------------------------------------*/