pls ,tell us the c coding for interfacing pir sensor with microcontroller at89c51
Posts: 14,118
Threads: 61
Joined: Oct 2014
PIR sensor interface to 8051
The 8051 considers any voltage between 2 and 5V on its port pin as HIGH and any voltage between 0 to 0.8V as LOW. Since the output of the PIR sensor module has only two stages (HIGH (3.3V) and LOW (0V)), it can be directly connected to the 8051 microcontroller. The circuit diagram for connecting the PIR sensor to the 8051 microcontroller .
The circuit shown above reads the status of the PIR sensor output and turns on the LED when there is a detected movement and turns off the LED when no movement is detected. The output plug of the PIR sensor is connected to the 3.5-pin port on the 8051. The resistor R1, the capacitor C1 and the push-button S1 form the reset circuit. The capacitors C3, C4 and crystal X1 are associated with the oscillator circuit. C2 is only a decoupling capacitor. The LED is connected through the microcontroller port 2.0. Transistor Q1 is used to switch the LED. R2 limits the base current of the transistor and R3 limits the current through the LED. The program for connecting the PIR sensor to 8051 is shown below.
Program
Code:
PIR EQU P3.5
LED EQU P2.0
ORG 00H
CLR P2.0
SETB P3.5
HERE:JNB PIR, HERE
SETB LED
HERE1:JB PIR,HERE1
CLR LED
SJMP HERE
END