Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C language please? Design a Simple home security alarm system that will sound

ID: 3856979 • Letter: I

Question

In C language please? Design a Simple home security alarm system that will sound a siren if the system is armed (set alarm) and any of the following events occur: doors open in an unauthorized manner (assume only two doors) Windows open in an unauthorized manner (assume only three windows) Unauthorized movement inside the house (assume one ultrasonic motion sensor) Arming the system: resident is away (Fully Armed rightarrow door, windows and motion control) resident is in the house (Partially Armed, i.e. during the night rightarrow door and windows control only) requires correct 3 bit password (first 3 digits of your PS Id.) to arm the system RED LED to indicate the Fully Armed ORANGE LED to indicate partially armed One input pin is used to select between fully armed option or partially armed option 1 rightarrow fully armed 0 rightarrow partially armed Disarming the system: resident is in the house requires correct 3 bit password (first 3 digits of your PS Id.) to disarm the system after any 4 consecutive unsuccessful password entries, the siren will continuously sound until the correct password is entered GREEN LED to indicate disarming a. Draw the finite state machine for the security system. b. Draw the hardware circuit interface for the security system. c. Write the complete interrupt based ARM code. Assume all input ports for password entry are connected to Port B, all sensors are connected to Port C and all output ports are connected to Port D. Priority will be 1. d. Modify the above finite state machine for a home security system that has a smoke detector feature in addition to the motion detector.

Explanation / Answer

The question seems to be related to microprocessor (assembly level language) but as you asked to solve in C language my code goes as follows.

//gcc 5.4.0

#include <stdio.h>
int authenticate(int passWord,int entered_pwd)
{
if(passWord==entered_pwd) return 1;
else return 0;
}
void armSystem(int passWord)
{
int entered_pwd;
printf(" Enter password to arm the system : ");
scanf("%d",&entered_pwd);
if(authenticate(passWord,entered_pwd))
{
printf(" Successfully armed the system");
return ;
}
else
{
printf(" Wrong password try again");
armSystem(passWord);
}
}
void disarm(int passWord)
{
int entered_pwd;
printf(" Enter password : ");
scanf("%d",&entered_pwd);
if(entered_pwd==passWord) return ;
else
{
printf(" Entered wrong password try again : ");
scanf("%d",&entered_pwd);
if(entered_pwd==passWord) return ;
else
{
printf(" Entered wrong password try again : ");
scanf("%d",&entered_pwd);
if(entered_pwd==passWord) return ;
else
{
printf(" Entered wrong password try again : ");
scanf("%d",&entered_pwd);
}
}
}
while(1)
{
printf(" Entered wrong password try again : ");
scanf("%d",&entered_pwd);
if(entered_pwd==passWord) return;
else
{
printf(" ");// produces beep sound.
}
}
}
void fullyArmed(int passWord)
{
int door1=0,door2=0,window1=0,window2=0,window3=0,motion=0;//0-->everything normal 1-->something went wrong
printf(" Red To disarm enter 2");
scanf("%d%d%d%d%d%d",&door1,&door2,&window1,&window2,&window3,&motion);
if(door1==1||door2==1||window1==1||window2==1||window3==1||motion==1)
{
while(1)
{
printf("");
printf(" Something went wrong.");
disarm(passWord);
}
}
else if(door1==2||door2==2||window1==2||window2==2||window3==2||motion==2)
{
disarm(passWord);
return ;
}
fullyArmed(passWord);
}
void partiallyArmed(int passWord)
{
int door1=0,door2=0,window1=0,window2=0,window3=0;//0-->everything normal 1-->something went wrong
printf(" Red To disarm enter 2");
scanf("%d%d%d%d%d%d",&door1,&door2,&window1,&window2,&window3);
if(door1==1||door2==1||window1==1||window2==1||window3==1)
{
while(1)
{
printf("");
printf(" Something went wrong.");
disarm(passWord);
}
}
else if(door1==2||door2==2||window1==2||window2==2||window3==2)
{
disarm(passWord);
return ;
}
partiallyArmed(passWord);
}
int main(void)
{
//initializing 3 digit password
int passWord=123;
int mode_of_working=1;//1-->fully armed mode and 0-->partially armed mode
while(1)
{
armSystem(passWord);
printf(" 1 for fully armed mode 2 for partially armed mode Select mode of operation : ");
scanf("%d",&mode_of_working);
switch(mode_of_working)
{
case 1:
fullyArmed(passWord);
case 2:
partiallyArmed(passWord);
}
}
return 0;
}