Home > other >  Single chip microcomputer, guide the novice small white bosses genuflect is begged!!!!!!
Single chip microcomputer, guide the novice small white bosses genuflect is begged!!!!!!

Time:12-01

Using c language to write, really have no idea, try to write a few, are infinite loop
I'm terribly sorry that I also want to give, but I don't know why, don't let the

CodePudding user response:

What matters is attitude can not you give score! There's plenty seen people haven't reply?

CodePudding user response:

The polling state then it should not be difficult to control digital tube display this logic

CodePudding user response:

Do the simulation diagram, this topic to implement, is expected to be writing a decimal to binary, then corresponding to eight digital tube display,

CodePudding user response:

To my blog 16-way responder sample copy matrix keyboard code, the reply before the dynamic and static digital tube example is modified to display buttons defined the value of the sample program is as follows:

Program according to the digital display value from 0 to 15, the next step is to address send decimal to binary corresponding digital display,

CodePudding user response:

Dynamic display of digital tube press the binary combination keyboard keys:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Dynamic display of experimental phenomena: press the binary combination keyboard keys
Connection details: single chip microcomputer, & gt; Digital tube dynamic module
J22 - & gt; J6
P22 - & gt; J9 (A)
P23 - & gt; J9 (B)
P24 - & gt; J9 (C)
J-20 - & gt; JP3
Note:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

# include "reg52. H"//this file defines the MCU some special function register

Typedef unsigned int under-16;//to statement defines the data type
Typedef unsigned char u8;

# define GPIO_DIG P0
# define GPIO_KEY P1

Sbit LSA=P2 ^ 2;
Sbit LSB=P2 ^ 3;
Sbit LSC=P2 ^ 4;

U8 code smgduan [17]={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07,
X6f 0 x7f, 0, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};//show the value of 0 ~ F

U8 KeyValue;//used to store the keys of the read
U8 KeyValueold;//

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* letter of several: delay
* function function: delay function, I=1, delay about 10 us
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void delay (under-16 I)
{
While (I -);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* letter of several: DigDisplay
* function features: digital tube dynamic scanning function, circulation scanning eight digital tube display
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void DigDisplay (u8 jz)
{
u8 i;
U8 ls=0 x80;

for(i=0; i<8; I++)
{
If ((jz & amp; (ls> I))==0)
{
P0=smgduan [0];
Switch (I)//person, choose the digital tube light,
{
Case (0) :
LSA=0; LSB=0; LSC=0; break;//show a 0
Case (1) :
LSA=1; LSB=0; LSC=0; break;//show the first bit
Case (2) :
LSA=0; LSB=1; LSC=0; break;//show the second
Case (3) :
LSA=1; LSB=1; LSC=0; break;//show the third
Case (4) :
LSA=0; LSB=0; LSC=1; break;//show 4
Case (5) :
LSA=1; LSB=0; LSC=1; break;//show the fifth
Case (6) :
LSA=0; LSB=1; LSC=1; break;//show the sixth
Case (7) :
LSA=1; LSB=1; LSC=1; break;//show the 7th
}
Delay (100);//for a period of time between scanning
P0=0 x00;//blanking
}
The else
{
P0=smgduan [1];
Switch (I)//person, choose the digital tube light,
{
Case (0) :
LSA=0; LSB=0; LSC=0; break;//show a 0
Case (1) :
LSA=1; LSB=0; LSC=0; break;//show the first bit
Case (2) :
LSA=0; LSB=1; LSC=0; break;//show the second
Case (3) :
LSA=1; LSB=1; LSC=0; break;//show the third
Case (4) :
LSA=0; LSB=0; LSC=1; break;//show 4
Case (5) :
LSA=1; LSB=0; LSC=1; break;//show the fifth
Case (6) :
LSA=0; LSB=1; LSC=1; break;//show the sixth
Case (7) :
LSA=1; LSB=1; LSC=1; break;//show the 7th
}
Delay (100);//for a period of time between scanning
P0=0 x00;//blanking
}
}
}

Void KeyDown (void)
{
Char a=0;
GPIO_KEY=0 x0f;
If (GPIO_KEY!=0 x0f)/whether/read button press
{
delay(1000);//delay 10 ms away shaking,
If (GPIO_KEY!=0 x0f)//again to test whether the keyboard press
{
//test column
GPIO_KEY=0 x0f;
The switch (GPIO_KEY)
{
Case (0 x07) : KeyValue=https://bbs.csdn.net/topics/0; break;
Case (0 x0b) : KeyValue=https://bbs.csdn.net/topics/1; break;
Case (0 x0d) : KeyValue=https://bbs.csdn.net/topics/2; break;
Case (0 x0e) : KeyValue=https://bbs.csdn.net/topics/3; break;
}
//test
GPIO_KEY=0 xf0;
The switch (GPIO_KEY)
{
Case (0 x70) : KeyValue=https://bbs.csdn.net/topics/KeyValue; break;
Case (0 xb0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+4; break;
Case (0 xd0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+8; break;
Case (0 xe0-0xfc) : KeyValue=https://bbs.csdn.net/topics/KeyValue+12; break;
}

}
}
While ((a<50) & amp; & (GPIO_KEY!=0 xf0))//inspection buttons let go
{
Delay (100);
+;
}
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* letter of several: the main
* function function: the main function
No
* entered:No
* output:nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related