单片机P1口接一共阳极数码管,公共端已接高电频,请编写程序使数码管循环显示字符0~F,每个字符显示

如题所述

第1个回答  2018-03-25
#include<reg51.h>
unsigned char code table[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};//共阳极
void delay(int a)
{
unsigned char i;
while(a--)for(i=0;i<120;i++);
}
main()
{
unsigned char i;
while(1)
    {
    P1=table[i];
    delay(500);
    i++;
    i%=16;
    }
}

本回答被网友采纳
相似回答