?? max7219.c
字號:
/*福州天虹電腦科技有限公司 蘇秋錦2011年2月*/
#include <reg51.h>
#include <max7219.h>
/*數據字顯示說明*/
//顯示子令:Write_Max7219(位,內容):0至9數字;10-;11E;12H;13L;14P;15空格
/*定義針腳*/
//P0O-D //P01-8 //P02-4 //P03-2 //P04-1 //P05-R
void delay(unsigned int ii);
/*定義整體變量*/
unsigned int I;//臨時變量
char N;
char N1;
char N2;
char N3;
char N4;
/***************
主程序
***************/
void main(void)
{
P00=LOW;
P01=HIGH;
P02=HIGH;
P03=HIGH;
P04=HIGH;
P05=HIGH;
Disp_Max7219(15,15,15,15,10,0,1,10);
while(1){
if(P00==HIGH){ //有數據輸入,進行8421碼編譯
if(P04==LOW){N1=1;}
else{N1=0;}
if(P03==LOW){N2=1;}
else{N2=0;}
if(P02==LOW){N3=1;}
else{N3=0;}
if(P01==LOW){N4=1;}
else{N4=0;}
N=1*N1+2*N2+4*N3+8*N4;
Disp_Max7219(10,10,10,N,10,0,1,10);}
else{Disp_Max7219(15,15,15,15,10,0,1,10);}
delay(1);
if(P05==LOW){Disp_Max7219(10,12,12,10,10,0,1,10);}
}
}
/*延時程序*/
void delay(unsigned int ii)
{
unsigned int iii;
iii=1000;
for (I=1;I<=ii;I++)
{while(--iii);}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -