Question

In: Computer Science

For this lab, you are to construct a mock burglar alarm. The system will have three...

For this lab, you are to construct a mock burglar alarm. The system will have three states, armed, disarmed, and alarm, two inputs in the form of push buttons, and two outputs in the form of LEDs.

The system should start in the disarmed state with a green LED lit. Pressing button 1 moves us to the armed state, pressing button 2 (our stand-in for a door contact sensor) does nothing.

In the armed state, the red LED should blink off and on. Pressing button 1 disarms the system and returns to that state. Pressing button 2 transitions the system to the alarm state

In the alarm state, the red LED is solid (not blinking). Pressing button 2 does nothing while pressing button 1 disarms the alarm.

Can someone please create a writing schematic and code in Arduino?

Solutions

Expert Solution

Here I am writing the code in Arduino IDE and I am pasting sketch here also I will explain about that line after this // .

alarm sketch:

int push_button1=7; // declration of pin of push button and LED pins
int push_button2=8;
int green_LED=9;
int red_LED=10;
int val1=0,val2=0,i=0,j=0;   // taking some variable which will be use in program to make this system
void setup() {
pinMode(push_button1,INPUT);     //intializing pinmode of the LED's and push button's
pinMode(push_button2,INPUT);
pinMode(green_LED,OUTPUT);
pinMode(red_LED,OUTPUT);
disarmed_state();             // according to question system initial start with disarmed state so it's need to be in setup part
}
void disarmed_state()          // disarmed function that which we call in main function according to our use
{
digitalWrite(red_LED,LOW);   // if disarmed state is on so it needs to be red led off and green led on
digitalWrite(green_LED,HIGH);
}
void armed_state()              // creating armed state function which we call in the main function according to our use
{
digitalWrite(green_LED,LOW);    // armed state so it's need to be green led off and red led will blink
digitalWrite(red_LED,HIGH);    // red led on
delay(500);                    // give it to 0.5 sec time to be on
digitalWrite(red_LED,LOW);    // then off
delay(500);                   // again give it to 0.5 sc to off then it will again on because loop will run continue
}
void alarm()                    // alarm state function again we will call it according to our use
{
digitalWrite(green_LED,LOW);   // in this state green led need to off
digitalWrite(red_LED,HIGH);   //and red led to on
}
void loop() {                       //main function
val1=digitalRead(push_button1);    // read push button value when it will push then it value become 1 if push will realise then it's value become 0
val2=digitalRead(push_button2);    // similarly for pushbutton 2
if(val1==HIGH)                    //checking for input come or not if come val =1 and program enter to this loop
{
    i=1;                           
    delay(1000);     //   giving program to 1sec time to excute properly
    while(i)         // when i =1 then program enter to while loop it will run in this loop untill i become 0
    {
      armed_state(); //calling armed state because according to question when push button 1 is press then it will go to armed state
      if(val1==HIGH) // again checking for new input from push button 1
      {
        disarmed_state(); // if come then program will go to disarmed state
        i=0;    // and i become 0 and program will exit this loop
      }
    }
}
if(val2==HIGH && i==0) // now if push button 2 will press and push button 1 not pressed or system neither in any state
{
    j=1;    // then program will enter in this loop
    delay(500); // giving 0.5 sec time to program for work properly
    while(j)   // enter in while loop when push button2 will pressed and system not in any state or in disarmed state
    {
      alarm(); // alarm state will activate
      if(val1==HIGH) // again checking for push button 1 input if come
      {
        delay(500);
        disarmed_state(); // then disarmed state will activate
        j=0;          // and program will exit this loop
      }
    }
}
}


Related Solutions

The following applications such as a home burglar system, combined household heating and cooling system, and...
The following applications such as a home burglar system, combined household heating and cooling system, and hospital recovery room are essential to our daily lives. Please Answer the following three questions. What are the physical quantities that need to be measured for each application and why they are important? Discuss any limitations and trade-offs that are involved in each application. Lastly, Identify the sensor category and sensor technology that could be used. Be sure to explain your reasoning.
Create a mock corporate compliance and risk management plan: You have been tasked with creating a...
Create a mock corporate compliance and risk management plan: You have been tasked with creating a corporate compliance and risk management plan for a small, rural public community hospital. In a minimum of 1000 words, discuss the steps you would take to create the plan, what specific areas you feel should be covered based upon the demographics of patients being served and how your plan will ensure patients are receiving quality care? with references.
You have been hired by a home security company to design and implement a home alarm...
You have been hired by a home security company to design and implement a home alarm system. The logic of the system is as follows: once the alarm system has been armed, it is to sound if the front door is opened, the back door is opened or either of two windows is opened (you can assume there are only two windows). Design the necessary circuit to implement the situation described above. Your circuit should have five inputs (A =...
design a circuit of an alarm system that has buzzer that rings for 2 minutes and...
design a circuit of an alarm system that has buzzer that rings for 2 minutes and LED'S that flicker for 2minutes.
Can you explain associated alarm of TENS?
Can you explain associated alarm of TENS?
On December 31, 2019, AAA Security sold an alarm system to Wondermart in exchange for a...
On December 31, 2019, AAA Security sold an alarm system to Wondermart in exchange for a 3-year, $900,000 non-interest-bearing note. Wondermart will make three equal yearly payments to repay the note. AAA’s year-end is December 31. Wondermart would normally pay an interest rate of 5%. Required Calculate the present value of the note and present a loan amortization table. AAA follows IFRS and therefore uses the effective interest method. Calculate amounts to the nearest dollar. Prepare all journal entries required...
A hotel is looking to replace its outdated alarm system to comply with safety standards. It...
A hotel is looking to replace its outdated alarm system to comply with safety standards. It has two options: System A costs $35,000 and lasts nine years. System B costs $22,000 and lasts six years. Maintenance throughout the year will cost $2,000 for System A and $3000 for System B, recognized at the end of each year. The hotel’s cost of capital is 10%. Which alarm system should the hotel choose? (Please Show work and explain answer)
Create a high-level design for a home alarm system. Assume that there are 4 windows and...
Create a high-level design for a home alarm system. Assume that there are 4 windows and 2 doors. The windows and doors have light sensors, so if any object crosses the light path, an appropriate event will be registered. Also, each window and door has latches with sensors that detect if the latch has been turned. Your solution will consist of the following parts 1.       Use a variable “Armed” to allow a user to arm the alarm system. So if a...
Identify and describe 3 (three) key smoke alarm maintenance routines you must follow to provide effective...
Identify and describe 3 (three) key smoke alarm maintenance routines you must follow to provide effective protection.
Identify and describe 3 (three) key smoke alarm maintenance routines you must follow to provide effective...
Identify and describe 3 (three) key smoke alarm maintenance routines you must follow to provide effective protection.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT