51单片机数码管显示程序
不知道是程序错了还是电路不对,我的数码管单片机仿真结果错误。#include<reg52.h>#defineucharunsignedchar#defineuintuns...
不知道是程序错了还是电路不对,我的数码管单片机仿真结果错误。
#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<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; } } } 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询