51单片机单个数码管循环显示0~9

#include"reg52.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
u8 code sumagd[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,
0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(u16 i)
{
while(i--);
}
void main()
{
u8 i;
a=0;
b=0;
c=0;
while(1)
{
for(i=0;i<10;i++)
{
P0=sumagd[i];
delay(50000);
}
}
}

你可能感兴趣的:(51单片机单个数码管循环显示0~9)