|
include <reg51.h>
/ E5 ^+ r9 ?' K& f5 v; _' e#define uchar unsigned char
, u- l/ v# B: A0 S6 C7 E2 @#define uint unsigned int" `6 C: N; n, b8 Q1 e" _4 n3 B
/ M6 V! M$ G+ g# x1 Xsbit INT1=P3^1;中断0
D. g# t6 p$ n k* asbit FEN=P3^6; 蜂鸣器 g: i+ @) Q5 Q5 U2 u
: c9 G( x' Y( q4 Gvoid delay(uint x)
- L' Y- z O; {, U/ P- \) I0 G{
& E3 E- S; X/ O+ i. m" N5 |. } uint a,b;
% k5 u& k1 {" y9 ~7 s7 r3 i for(a=x;a>0;a--)
' l0 P, Z" n* w. s* ^6 w' ? for(b=10;b>0;b--); ) R O3 ?/ h, K7 g5 @' L% G
}& q, _( `' G4 s
9 l& @( L3 j; A* R* umain()! s& M$ T# [' W; E
{
+ X" l7 O7 d! E3 U. E) `8 \ EA=1;//开总中断 E3 r. m# |! C2 k' u" o
EX0=1;//开外部中断03 N% p; t* R: M& V& S7 N
8 T5 i# e, O: ?. I9 B
while(1);$ F* ^' X3 T. r" X7 L2 v2 D
}
, A/ d- q9 U! W! pvoid exter0() interrupt 0
* R+ J; Y9 j* L. U0 ~{$ A+ A2 J- ?" p9 O) C
FEN =0;" W% U0 P$ Y6 {0 M
delay(1000);+ Q Q9 ], {( n9 J% t
FEN=0;
: l3 l9 j( G3 q0 h}8 m( S0 G& s5 J# L. L
0 L5 c6 K' }# E1 B6 N- H( K9 z7 N. r: k6 K* a
" m8 M" G" e; u2 Y我忘了外部中断0的引脚了,记得好像是3.1,你回去查查,如果是就不用改了,不是就把这个引脚改过来,这个引脚接红外传感器的输出。 |
|