#include "display.h"
unsigned char table[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x7f};
//将一个四位数num显示到数码管上
void display(int num)
{
unsigned char g,s,b,q;
g = num % 10;
s = num / 10 % 10;
b = num / 100 % 10;
q = num / 1000 % 10;
WEI0 = 0;//打开位选
P0 = table[g];
delay_ms(1);
WEI0 = 1;
WEI1 = 0;
P0 = table[s];
delay_ms(1);
WEI1 = 1;
WEI2 = 0;
P0 = table[b];
delay_ms(1);
WEI2 = 1;
WEI3 = 0;
P0 = table[q];
delay_ms(1);
WEI3 = 1;
}
|