You must have come in to a situation where you will like to have or make a device capable of detecting the presence of persons. Worry not because it is exactly what we will be doing today.
A trespass detector is a normally a device that can be positioned at a targeted area to detect the presence of persons or animals entering a particular place legally or illegally depending on one’s objectives.
A typical example is at the entrance of a bank safe, to alert the manager in case there’s an intruder to the safe.
Things needed to construct the trespass detector.
Step 1: Tools and materials
IR Transmitter (5mm LED) X 1
IR receiver (5mm photo-diode) X 1
10k resistor X 4
1k resistor X 1
120 Ohms resistor X 1
330 ohms resistor X 1
470 Ohms resistor X 1
BC547 transistor X 1
NO push button X 1
16X2 LCD X 1
5V buzzer X 1
Green LED X 1
10K potentiometer X 2
Lm 358 X 1
8 pin IC socket
40 pin IC socket
4MHz Crystal X 1
PIC16F877A
LM35
A soldering iron and some solder
Jumper wires and breadboard wires
Wire cutter
A breadboard
4.318cm x 2.667cm copper board
See how to make IR Sensor here.
Step 3: Circuit Diagram
After constructing the above circuit on your breadboard, upload the compiled hex file in to the micro-controller (pic16f877a) using a PIC Programmer and test the system for proper functioning.
Step 4: The source code
The source code was written and compiled using MikroC pro for PIC. Download the source code here.
// Trespass detector with fire outbreak arlarm// PIC16F877A// https://lrn2make.com
#define MAX_TEMP 30#define MAX_Tp 700
sbit LCD_RS at RB0_bit;sbit LCD_EN at RB1_bit;sbit LCD_D4 at RB2_bit;sbit LCD_D5 at RB3_bit;sbit LCD_D6 at RB4_bit;sbit LCD_D7 at RB5_bit;
sbit LCD_RS_Direction at TRISB0_bit;sbit LCD_EN_Direction at TRISB1_bit;sbit LCD_D4_Direction at TRISB2_bit;sbit LCD_D6_Direction at TRISB3_bit;sbit LCD_D5_Direction at TRISB4_bit;sbit LCD_D7_Direction at TRISB5_bit;
sbit reset at RD1_bit; //reset buttonsbit alarm at RD0_bit; //relaysbit alarm_led at RD2_bit;char temp[4];unsigned int temperature(){return adc_read(0) / 2;}
void Home_scr(){lcd_cmd(_lcd_clear);lcd_out(1,1,"Temp: ");lcd_out(1, 9, "C");lcd_out(2,1,"System Normal");}unsigned int trespass(){return adc_read(1);}
void main() {ADCON1 = 0X00;TRISD = 0b00000010;TRISA = 0XFF;alarm =0;alarm_led =0;lcd_init();lcd_cmd(_lcd_cursor_off);LCD_out(1,1,"System Normal");delay_ms(1000);lcd_cmd(_lcd_clear);Home_scr();while(1){bytetostr((unsigned short)temperature(), temp);lcd_out(1,6,temp);if(temperature() > MAX_TEMP){alarm = 1;alarm_led =1;lcd_cmd(_lcd_clear);lcd_out(1,1,"FIRE OUTBREAK!!!");while(!reset){}delay_ms(200);alarm = 0;alarm_led =0;Home_scr();}if(trespass() > MAX_Tp){alarm = 1;alarm_led =1;lcd_cmd(_lcd_clear);lcd_out(1,1,"ALERT");lcd_out(2,1,"Trespass Detect!");while(!reset){}delay_ms(200);alarm = 0;alarm_led =0;Home_scr();}}}
Step 5: How to upload the compiled HEX file using PICKIT2 programmer
Please, follow the tutorials here (With pictures).
Step 6: Realization Process
Download the top silk and bottom copper at the end of this article.
Top silk
Bottom copper
Step 7: Working Video
Coming Soon….
Step 8: Downloads
Download the complete project in a zip folder here
Step 9: Done!
Thanks for reading.
Please don’t leave the page without sharing with others what you think about this article in the comments section below.
Press Like and share, thanks
