อุปกรณ์
- PicKit 3
- PIR Sensor.
- PIC16F877A IC
- 40 - Pin IC holder
- Perf board
- 20 MHz Crystal OSC
- Female and Male Bergstick pins
- 33pf Capacitor - 2Nos, 100uf and 10uf cap.
- 680 ohm, 10K and 560ohm Resistor
- LED of any color
- 1 Soldering kit
- IC 7805
- 12V Adapter
- Buzzer
- Connecting wires
- Breadboard
code
#include <xc.h>
#define _XTAL_FREQ 20000000 //Specify the XTAL crystall FREQ
#define PIR RC0
#define Buzzer RB2
#define PIR RC0
#define Buzzer RB2
void main() //The main function
{
TRISB=0X00; //Instruct the MCU that the PORTB pins are used as Output.
TRISC=0Xff; //Instruct the MCU that the PORTB pins are used as Input.
PORTB=0X00; //Make all output of RB3 LOW
{
TRISB=0X00; //Instruct the MCU that the PORTB pins are used as Output.
TRISC=0Xff; //Instruct the MCU that the PORTB pins are used as Input.
PORTB=0X00; //Make all output of RB3 LOW
while(1) //Get into the Infinie While loop
{
if(PIR ==1){
Buzzer=1;
__delay_ms(1000); //Wait
}
else{
Buzzer=0;
}
}
{
if(PIR ==1){
Buzzer=1;
__delay_ms(1000); //Wait
}
else{
Buzzer=0;
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น