/* A door sensor is connected to the P1.1 pin, and a buzzer is connected to P1.7.
Write a program to monitor the door sensor, and when it opens, sound the buzzer.
You can sound the buzzer by sending a squre Wave of a few hundred Hz. */
#include
sbit DorSensor = P1^1;
sbit Buzzer = P1^7;
void main(void)
{
Buzzer=0;
DorSensor=0;
while(1)
{
if(DorSensor)
Buzzer = 1;
else
Buzzer =0;
}
}