Sie sind auf Seite 1von 1

#include<reg51.

h>
sfr rfr=0x90;
sfr mtr=0xB0;
sbit pir=p2^0;
sbit buz=p2^3;
void detection(void);
void main()
{
rfr=0xFF;
buz=0;
while(1)
{
if(rfr==0x0E)
{
mtr=0x05;
}
elseif(rfr==0x0D)
{
mtr=0x0A;
}
elseif(rfr==0x0B)
{
mtr=0x02;
}
elseif(rfr==0x07)
{
mtr=0x08;
}
elseif(rfr==0x0C)
{
detection();
}
elseif(rfr==0x0F)
{
mtr=0x00;
buz=0;
}
else
mtr=0x00;
buz=0;
}
}
void detection()
{
unsigned inti;
mtr=0x00;
if(pir==1)
{
buz=1;
for(i=0;i<200;i++);
}
else
buz=0;
}

Das könnte Ihnen auch gefallen