📄 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 + -