Home > other >  Single chip microcomputer, digital GuanGaiCheng dot matrix display how to code how to change
Single chip microcomputer, digital GuanGaiCheng dot matrix display how to code how to change

Time:12-29


#include
# define uchar unsigned char
# define uint unsigned int
Bit enabled=0;
Sbit led_enabled=P3 ^ 0;
Sbit alarm=P3 ^ 1;
Uchar buzzer_code;
Uchar code disp_code [12]={xa4 xc0 0, 0 xf9, 0, 0, xb0 x99 0, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90, 0 XFF, 0 XBF}; 4
//Yang glyph code
Void delay_ms (uint I)
{
Uint j;
While (I -)
{
For (j=0; J & lt; 125; J++);
}
}

Void int0_isr () interrupt 0
{
Enabled=! Enabled.
If (enabled==1)//host press the "start" key, allowing vies to answer first,
Led_enabled=0;//light vies to answer first allow light
The else
{
Led_enabled=1;//host again press the "start" button, close the vies to answer first allow light
The P2=0 XFF;//close all the vies to answer first the light
P0=0 XFF;//out of digital tube display vies to answer first number
}
}
Void int1_isr () interrupt 2
{
uchar temp;
EA=0;//close the interrupt, prevent new vies to answer first button press the trigger interrupt
Temp=p;//vies to answer first person according to the key information
The P2=temp;//vies to answer first the lights lit
If (enabled==0)//if someone before has not allowed vies to answer first vies to answer first, the alarm
Alarm=0;
The switch (temp)//according to according to the key information acquisition vies to answer first vies to answer first the Numbers,
{
Case 0 xfe: buzzer_code=1; break;
Case 0 XFD: buzzer_code=2; break;
Case 0 XFB: buzzer_code=3; break;
Case 0 xf7: buzzer_code=4; break;
Case 0 xef: buzzer_code=5; break;
Case 0 XDF: buzzer_code=6; break;
Case 0 XBF: buzzer_code=7; break;
Case 0 x7f: buzzer_code=8; break;
default:break;
}
P0=disp_code [buzzer_code];//display vies to answer first person number
Delay_ms (1000);
//delay a period of timeAlarm=1;//to turn off the alarm
EA=1;//open the interrupt, allowed to receive new interrupt
}

Void main ()
{
EX0=1;
EX1=1;
IT0=1;
IT1=1;
EA=1;
P1=0 XFF;//for reading P1 mouth connection button, the first to put the corresponding port 1

While (1);
}

CodePudding user response:

Anti-settling ZSBD
  • Related