Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Idea for writing code for an Alarm system

Status
Not open for further replies.

pic_programm3r

New Member
hi all,

im currently working on a PIC based project and not too sure on how to write a bit of code for it. i'm doing an alarm system that uses a keypad code to arm/disarm the alarm.

when the alarm is armed and a presence is detected the alarm allows 10 seconds to enter the correct code to disarm it otherwise the alarm siren will go off.

i am not sure on how to write the code for when the alarm is armed, how can i scan the keypad and verify if the correct code is entered within 10 seconds with the process of checking the correct code and a 10 second countdown happening at the same time.

I am writing the code in PIC C. Any ideas based around PIC C code or PIC assembly code would be much appreciated.

Thanks
 
Last edited:
I would do something like,
Code:
    Count=0;
    Code="1234";
    Correct=0;
    while(Correct!=4 && Count!=1000){
        DelaymS(10);
        Key=ReadKeys();
        if(Key==Code[Correct]){
            Correct++;
        }
        Count++;
    }
    if(Count==1000){
        DoAlarm();
    }
    else{
        //is correct
    }

Hope that helps.

Mike.
 
managed to find the solution to the problem. it ended up being the +5v wire that needed to be pulled out after the hardware had been programmed something to do with the pull up resistors. i had previously known about this but forgot since its been a year since i needed to program a keypad.
 
Status
Not open for further replies.

Latest threads

Back
Top