51单片机led数码管显示0-99静态程序
2个回答
展开全部
假设P0 P2口接数码管 程序如下
include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar num=0;
//共阴数码管七段码
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77};
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void main(void )//主程序
{
while(1)
{
delay_ms(1000);
num++;
if(num==100)num=0;
P0=table[num/10];
P2=table[num%10];
include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar num=0;
//共阴数码管七段码
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77};
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void main(void )//主程序
{
while(1)
{
delay_ms(1000);
num++;
if(num==100)num=0;
P0=table[num/10];
P2=table[num%10];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询