EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
汽车灯程序,相关软件 + S. G2 K% i" m7 h
#include<at89x51.h> ! h: \& S* y& }0 x4 [9 S* J
void delay(unsigned char a) 0 Z# s. i6 X% F+ N- E* ], b; b( N
{
$ h P% P. P, i: I$ V9 F4 V' z. junsigned char j,y; 2 K) I8 ?9 W( s1 c2 @
for(j=0;j<a;j++) ' K6 n5 r* z. H. Q; b a* i* n
for(y=0;y<115;y++);
7 |: P- t3 c8 }0 p& R5 F# N* b# P0 c}
$ ], R" i* H5 T% h- @% B6 ^7 Uvoid main() / D% a; k9 Z& `2 E
{ 3 N; l* N, L- a/ c# S n) s
unsigned char x; / w" f" W6 O z$ z a
P0=0x00;
2 h1 t- a/ Z* ~$ g5 j0 W! kwhile(1)
) s, b' g" T: U0 I{ ( ~5 Z) E) H# s. x* i7 R o& Z- f0 s H# b
/**********************************/
; R. _7 l7 P/ [$ l. B% HP1=0xff;
; P% _- W7 w, ^2 }# dx=P1;
7 Z3 t' k2 m, P/ w% V# |x=~x; $ G& z* F0 K6 S0 e" l) h
if(x==0)continue;delay(10); & s: G* n! y8 s
x=P1; ; c5 F! L# O, S1 B$ W
x=~x;
d& Q# G! m0 ?* q$ [if(x==0)continue;
/ m$ Y4 B- Y6 ^ _. h8 A8 nif(P1_0==0)/*****左转****/
: j: |% y9 |* M2 W) e: X{
6 e M. {/ B5 x: i6 [6 ]P0=0x15;delay(100)  0=0x00;delay(100);}
2 ~3 g# w6 G- z. N: belse if(P1_1==0)/**右转**/ 6 l3 Y+ x* y% d; }# D
{P0=0x2a;delay(100)  0=0x00;delay(100);}
7 I; g7 ^8 a3 {/ N- j0 ?else if(P1_2==0)/**刹车**/
1 b) h) L8 ~% |; a2 C0 P{while(P1_2==0){P0=0x30;}P0=0x00;} + d5 b, y2 _; }, x) @* L
else if(P1_3==0)/**紧急**/ * C- A4 j: K: E3 J7 r4 w& ~
{P0=0x3f;delay(100)  0=0x00;delay(100);}
: I+ n4 c3 g. s U0 oelse
$ ^3 i" V9 I+ BP0=0x00; : i3 ]0 M! w0 _0 n& V; u
} 0 L& k4 o" O5 j5 r1 M. c- N
}
* u9 B4 E5 \% v. l0 J5 }* h6 k
& `' j. G( G: l- N0 J8 X 5 q% a$ Z5 |5 n& }
0 }/ J$ l4 ~+ ~" _0 E) C* X4 ?, y( v
|