/************************************************ 跳線設置:雙排針除PSEN外全部插上 硬件結構框架: 1,八位八段數碼管 2,MCU STC89C52 顯示效果: 1,在數碼管上循環顯示0-9 相關知識點: 1,數碼管的驅動顯示方式 ************************************************/
#include"AT89x52.h" #include"math.h" #define uint unsigned int #define uchar unsigned char
sbit DUAN=P2^6; //74HC573的LE端 U1 數碼管LED的段選端 sbit WEI=P2^7; //74HC573的LE端 U1 數碼管LED的位選端 uchar Temp[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //共陰顯示字庫
void delay(uint z) //1ms延時 { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); }
main() { uchar i; DUAN=1; WEI=1; //讓第2個74hc573處于直通狀態 P0=0; //開啟所有數碼管的位選 WEI=0; //鎖存,保持第2個74hc573的輸出數據保持不變 while(1) { for(i=0;i<10;i++) { delay(500); //延時 P0=Temp; //送段碼 delay(500); } } }
|