Hi Guys!

This is a project that I made using pic microcontroller its an Electronic PIN Code Security System with real time clock and user define pin code features, this page contains all the details to make one yourself.


Well by turning Security System on, it will ask for a PINCODE to open gate, (its 140595) if you enter it correct, the door will open. Door is opened for 1 min only, then its closed again. If you enter pin code wrong Security System will give you 3 more chances, if all chances are wasted then it turns buzzer on, and asks for alternative code to stop buzzer, if this alternative code (i.e. 1984) is entered correctly then:

1) It stops buzzer

2) Resets original code which was 140595

3) Asks new code to replace original code which was 140595 (not more then 6 digits)

now the gate will be opened by this new code.

Suppose a wrong alternative code is inserted then System asks to wait for countdown of 1 min during which all buttons are disabled and buzzer keeps ringing.



sorry i haven't uploaded the video to any video site yet.


Before we get started, I am assuming that you already have basic knowledge of C language and have worked on MikroC pro before and that you know how to glow an LED, how to interface a LCD with a PIC Microcontroller. Okay lets get started !

Step 1: Gathering Components


1) 1 16x2 LCD Pin 14 to Pin 1 then Pin 15 and Pin 16 pins package.

2) 1 PIC18F4550 Microcontroller

3) 1 PCF8583 Real Time Clock (RTC) IC

4) 14 Reset Buttons Instead of Keypad I used reset buttons

5) 1 9v Battery Main power supply.

6) 1 10K Ohm Pot For setting contrast of LCD

7) 2 3.5mm audio jacks for externally connecting buzzer and gate

8) 1 100uF Capacitor Ceremic cap for using with pin1 of controller.

9) 1 32.682kHz Crystal For PCF8583 IC

10) 1 DC Power Jack If using project with a DC adapter

11) 1 IC7805 For converting 9V to 5V

12) 1 1K Ohm resistor for using with pin1 of controller.

13) 3 10K Ohm resistor for using with pin1 of controller and RTC IC

14) 13 220 Ohm resistor each button will use 1 220 Ohm I'll explain later

15) 1 3V Cell for using with RTC IC

16) 1 TICK TICK Switch

17) 1 PCB Board your choice if your comfortable on verro its fine.

18) 1 8 pin DIP for RTC IC

19) 1 40 pin DIP for PIC184550 or you can Zip socket if you want

20) 1 3V Cell holder

21) 1 9V Battery holder

22) 1 male header for soldering with LCD

23) 1 female header for soldering on PCB or verro where LCD will be placed.


20) Breadboard for testing

21) Soldering iron

22) Soldering wire

23) PIC Programmer (or PICKIT2)

24) Etching solution (for PCB)

25) PCB Drill

26) Multimeter

One think you'll notice I haven't included a crystal for PIC Microcontroller right ? Well thats because I used internal Oscillator of PIC18F4550



You can test the circuit on proteus, so you can get an idea about the project.

The proteus file will require a hex file for PIC microcontroller.

Both files are provided.

Step 3: Making PCB

I will recommend you to build this project on PCB don't use verroboard.

Print this PCB, it was designed on Cadsoft Eagle by me. If you have cadsoft eagle installed open up brd file (download below) and generate file according to your requirement of page size.

Otherwise I have attached two files on is of A4 and other is A5, print and check place components then print your PCB. I am asking this because there may be a page scale factor.

You can power up project by either a battery which is to be connected to the connector near to 7805, watch out for polarity. OR you can power up project by an adapter through the DC Power jack. The power sources can be switched by the tick tick button, when button is bushed inside the circuit powers up from external source through connector, when button is pushed outside the circuit powers up from DC power jack.

Step 4: Soldering Components

Solder all components, see the pictures attached.

On thing i have to tell you, since proteus is ideal thats why the buttons are connected directly to the microcontroller pin without a resistor.

But in real life a noise factor exists.

Like suppose, in this project if you press button 4 one time, on proteus you'll get 4 on LCD, but if you press it in real life you'll get 44444444 on LCD due to noise. ITo remove this the pcb contains 220 Ohm resistor with every button.

Step 5: Programming RTC IC PCF8583

Okay this is a little tricky thing but since code is provided it won't be that tricky. I did not gave .hex file for programming RTC IC since you have to generate it to set you required time, also the year is set to 2015 you don't have to set it.

Open up mikroC Pro fro PIC and select PIC18F4550, copy and paste the code below:

// LCD module connections
sbit LCD_RS at RB2_bit;

sbit LCD_EN at RB3_bit;

sbit LCD_D4 at RB4_bit;

sbit LCD_D5 at RB5_bit;

sbit LCD_D6 at RB6_bit;

sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;

sbit LCD_EN_Direction at TRISB3_bit;

sbit LCD_D4_Direction at TRISB4_bit;

sbit LCD_D5_Direction at TRISB5_bit;

sbit LCD_D6_Direction at TRISB6_bit;

sbit LCD_D7_Direction at TRISB7_bit;

// End LCD module connections

void main() {

ADCON1 = 0x0F;

CMCON |= 7; //Disable Comparators

OSCCON = 0b01111111; //Using internal Oscilator @ 8MHz

TRISB = 0x00; //PORTB for output (LCD)

LATB = 0xFF; //PORTC for input

LATC = 0xFF; //PORTD for input

TRISA.RA2 = 0; //RA2 for output

TRISA.RA3 = 0; //RA3 for output

UCON.USBEN = 0; //Disable usb UCFG.UTRDIS = 1;

TRISD = 0xF9; //PORTD output

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

Lcd_Out(1,1,"Setting Time...");


I2C1_Init(100000); // initialize full master mode

I2C1_Start(); // issue start signal

I2C1_Wr(0xA0); // address PCF8583

I2C1_Wr(0); // start from word at address 0 (configuration word)

I2C1_Wr(0x80); // write $80 to config. (pause counter...)

I2C1_Wr(0); // write 0 to cents word

I2C1_Wr(0); // write 0 to seconds word

I2C1_Wr(0x10); // CHANGE THIS 10 to whatever minutes you want to set

I2C1_Wr(0x17); // CHANGE THIS 17 to whatever hour you want to set

I2C1_Wr(0x23); // CHANGE THIS 23 to whatever date you want to set

I2C1_Wr(0x2); // CHANGE THIS 2 to whatever month you want to set

I2C1_Stop(); // issue stop signal

I2C1_Start(); // issue start signal

I2C1_Wr(0xA0); // address PCF8530

I2C1_Wr(0); // start from word at address 0

I2C1_Wr(0); // write 0 to config word (enable counting)

I2C1_Stop(); // issue stop signal


Lcd_Out(1,1,"Time Set.!");



_________________END CODE_________________

Generate a hex file from Mikroc Pro for PIC after compiling above code then burn it to pic microcontroller PIC18F4550

Place it on the pcb soldered with all components, turn it on. The LCD should display "Setting Time..." then when it displays "Time Set!" turn power off. Remove PIC microcontroller from DIP your have successfully programmed PCF8583 RTC IC. :)

Step 6: Programming PIC18F4550

Well the hex file is already provided in Step2 you can burn it to your PIC18F4550 through PIC Programmer.

Step 7: Last Step & FINAL TEST...!!

Attach an LED to the lower right 3.5mm audio jack and a buzzer to the upper right 3.5mm jack. Place your programmed PIC18F4550 on pcb and turn power on.

When correct code is entered it gives logic 1 to lower led, I assumed when giving logic 1 to led it opens up gate.

You Electronic Security System should be ready now...! And if you have done every thing write it should work fine.

you see the video below, its a fb link the video is public:


Sorry it haven't upload it to any video site yet.

<p>This looks great! I remember programming a very basic security system in assembly a few years back. Super fun! </p>
<p>well assembly is tough, so in my opinion that security system was not basic :D </p>

About This Instructable




Bio: 3rd Year student of Electronic Engineering at Sir Syed University Of Engineering & Technology, Karachi. Love to do new things and making cool projects...!
More by Shahrukh49:The CHAMPION 4Omni Wheel Soccer Robot ! Obstacle Avoiding Robot with IR Sensors without Microcontroller Electronic Security System with RTC and User define pin code 
Add instructable to: