|
7七段數(shù)碼管.png (17.18 KB, 下載次數(shù): 36)
下載附件
2018-6-22 16:40 上傳
) o) ~. @& i6 d# ^9 _( H, P" p
#include<reg51.h>
% E/ c; Q) C! ?6 O/ p5 q, c4 n9 i* c#include<intrins.h>
/ i9 b; G; F7 q' H4 W- o# v#define uchar unsigned char
9 X8 P6 @0 S8 v#define uint unsigned int
0 f0 c2 Q5 f$ Muchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};& G. a. v/ L- T. P# j( b: L$ P
//延時(shí)
1 p8 u* r) W6 s( U6 Uvoid DelayMS(uint x)4 p' n" d: ~9 U
{/ C' F5 k) b1 e. M
uchar t;1 r9 @3 a& Q: V' |( ?( e( c y
while(x--) for(t=0;t<120;t++);2 M; q3 K7 u4 W* R6 B6 a
}
/ R# `: a- N7 o, O- Q, F//主程序! n9 ]0 V5 ^2 `! |5 Y' w+ G
void main()
1 I9 \) H K- C$ I{
& i* N6 ]$ }- @' H t; u2 t3 Vuchar i=0;
* j0 }6 V* l4 h5 `# aP0=0x00;/ O" T& ]7 ?0 @* w }
while(1), l" X7 k! r/ g& I3 k& F" c) W; `
{3 p9 h6 _ h2 G8 P3 s/ l6 O2 E' T; e
P0=~DSY_CODE;2 H* z: j5 U9 r$ A: y" V# {$ _' C
i=(i+1)%10;
7 R5 u4 v- i, A5 t \* O4 ?DelayMS(300);1 h: T9 j' o6 t* y- [4 [! ` B# F
}9 B8 C, R3 z% t3 o
}
( K+ H% ~& ]7 h. m# m/ U" S+ o2 K
|
|