动态显示思路
逐个显示+极短的延时
例如在蓝桥杯开发板上动态显示U 3.14
#include"reg52.h"
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
unsigned char code duanma[]={~0x3F,~0x06,~0x5B,~0x4F,~0x66,~0x6D,~0x7D,~0x07,~0x7F,~0x6F,~0x77,~0x7C,~0x39,~0x5E,~0x79,~0x71,
//black - H J K L N o P U t G Q r M y
~0x00,~0x40,~0x76,~0x1E,~0x70,~0x38,~0x37,~0x5C,~0x73,~0x3E,~0x78,~0x3d,~0x67,~0x50,~0x37,~0x6e};
unsigned char code duanma_Dot[]= {~0xBF,~0x86,~0xDB,~0xCF,~0xE6,~0xED,~0xFD,~0x87,~0xFF,~0xEF,~0x46};
// 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. -1
void SelectHC573(unsigned char n){
switch(n){
case 4:
P2 = (P2 & 0x1f) | 0x80;
break;
case 5:
P2 = (P2 & 0x1f) | 0xa0;
break;
case 6:
P2 = (P2 & 0x1f) | 0xc0;
break;
case 7:
P2 = (P2 & 0x1f) | 0xe0;
break;
}
}
void Display(unsigned char value,unsigned char pos){
SelectHC573(7);
P0 = 0xff;
SelectHC573(6);
P0=0x01<<pos;
SelectHC573(7);
P0=value;
}
void InitSystem(){
SelectHC573(4);
P0=0xff;
SelectHC573(5);
P0=0x00;
}
void delay(unsigned char t){
while(t--);
}
void show(){
Display(duanma[31],0);
delay(50);
Display(duanma[25],1);
delay(50);
Display(duanma[10],2);
delay(50);
Display(duanma[22],3);
delay(50);
}
int main(){
InitSystem();
while(1){
show();
}
}