Blue Bridge Cup - digital

1. LED schematic description

        First find DS1 and DS2 digital schematics from the official schematic, as follows:

Can be seen from the schematic, the specific location of the diode shown and port P0 are controlled; when the digital initialization, the specific location can be a digital display, such as by changing the particular value P0: P0 = 0X01, the corresponding first and DS1 a digital display position; value is 0 for a single diode as light.

Note: a single diode display table 0-9: 0-0XC0; 1-0XF9; 2-0XA4; 3-0XB0; 4-0X99; 5-0X92; 6-0X82; 7-0XF8;

8—0X80;9—0X90;

Control buttons for the diode 2. Schematic

        If use keys P30-P36, J5 to pick 2 and 3, use P37, J5 to pick 1 and 2; corresponding to P30 S7, S7 when the press down, P30 = 0;

Similarly found: P31 and S6, P32 and S5, P33 and S4;

3. Specific examples of the realization of the function

3.1 implement particular location of the digital display

#include<stc15f2k60s2.h>
void main(){
P2=0XA0;P0=0X00;P2=0X80;P0=0XFF; //初始化
P2=0XC0;P0=0X01;P2=0XFF;P0=0XFF; //初始化,第一个P0=0X01对应DS1第一个位置显示数字;
while(1){
P0=0xA4; //	显示数字2;
}
}

3.2-button control of digital

#include<stc15f2k60s2.h>
void keycan();//按键函数声明;
void delay();  //延迟函数声明;
void main(){
P2=0XA0;P0=0X00;P2=0X80;P0=0XFF;
P2=0XC0;P0=0X01;P2=0XFF;P0=0XFF;	// 初始化,DS1第一个位置显示数字;
while(1){
keycan();
}
}
 //通过按键控制显示的数字
void keycan(){
if(P30==0){
     delay();
	 if(P30==0){
	 P0=0XF8;  //数字7
	 }
   while(!P30);
}
else if(P31==0){
     delay();
	 if(P31==0){
	 P0=0X82;	//数字6;
	 }
	 while(!P31);
	 }
else if(P32==0){
     delay();
	 if(P32==0){
	 P0=0X92;	//数字5;
	 }
	 while(!P32);
	 }
else if(P33==0){
     delay();
	 if(P33==0){
	 P0=0X99;	 //数字4;
	 }
	 while(!P33);
	 }
}
//定义延时函数delay
void delay(){
unsigned int i,j;
for(i=0;i<80;i++)
for(j=0;j<600;j++);
}


Control buttons may also be implemented digital omitted here by way of the array.

4. Conclusions and Requirements

        1, the digital portion is relatively simple, master schematics, know what each interface;

        2, an example of realizing digital display at a specific location of a specific number (such as; 9 displayed in the third digital DS2);

        

Published 14 original articles · won praise 11 · views 3059

Guess you like

Origin blog.csdn.net/fanjufei123456/article/details/104098193