菜鸟一个,请问把共阴极数码管改成共阳极,程序怎么改

2024-11-26 19:56:21
推荐回答(1个)
回答1:


uchar code LEDData[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
改为
uchar code LEDData[]=
{
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90
};


void Display_Result(uint d)
{
P3 = 0x7f;
P0 = LEDData[d%10];
DelayMS(5);
P3 = 0xbf;
P0 = LEDData[d/10%10];
DelayMS(5);
P3 = 0xdf;
P0 = LEDData[d/100%10];
DelayMS(5);
P3 = 0xef;
P0 = LEDData[d/10/100];
dp=1;
DelayMS(5);

}
改为
void Display_Result(uint d)
{
P3 = 0x80;
P0 = LEDData[d%10];
DelayMS(5);
P3 = 0x40;
P0 = LEDData[d/10%10];
DelayMS(5);
P3 = 0x20;
P0 = LEDData[d/100%10];
DelayMS(5);
P3 = 0x10;
P0 = LEDData[d/10/100];
dp=1;
DelayMS(5);
}