I am still having trouble with my coding. i am not sure how to do this. every thing i try doesn't work. I don't know how to use a select case statement to decode the keypresses
I am using this code (its the example code for reading the keypad) however i'm not sure what to do next to decode the presses and have it determine if it is correct or not. The goal is to have different subroutines for each individual press, and if the wrong button is pressed, it goes back to the first press subroutine. It was suggested to use a SELECT...CASE command to decode it, but i'm not sure how to. This is the example code for the keypad.
I figured out how to work the keypad, but I have another issue.
The alarm portion (Which includes the sound, IR sensor and indicator) has the sound go off the second the alarm is switched on. This should not be the case. The order of operation SHOULD be;
-Alarm is turned on
-Alarm searches for IR light
-When IR light is detected, The bi-color LED changes from Red to Green
-When something interrupts the IR detection (someone walks past) the bi-color LED becomes red again and the sound plays
-the alarm_out pin (P14) is turned on, setting off the keypad's micro-controller
-the song loops until the keypad code is correctly put in (this turns on valid_code_in, P15, which is the trigger for resetting the system)
-once valid_code_in is active, the entire thing resets
You need to initialize the system so the alarm is set to off before the main program loop is entered. Typically this is done with a variable that is set at the very beginning of the main program. For instance you could have a variable called state that is set to zero before the main program loop is entered.
In state 0 the alarm is off, the detector is not monitored, and the keypad is checked for a valid code to turn the system on and change the state to 1.
In state 1 the alarm is off, the detector is monitored, and the keypad is checked for a valid code to turn the system off and change the state back to 0.
If the detector is triggered the state is changed to 2, the alarm is turned on, and the keypad is checked for a valid code to turn the system off and change the state to 0.
To identify a correct/ incorrect password, create a series of variables that obtain values, and then compare them to constants containing the values for the correct password. If correct, run a procedure for enabling/disabling the alarm system. If incorrect, then either simply deny the password, or start a counter variable to set the number of safe incorrect password attempts. When the counter reaches the desired limit, trigger the alarm.
Comments
Mike
The alarm portion (Which includes the sound, IR sensor and indicator) has the sound go off the second the alarm is switched on. This should not be the case. The order of operation SHOULD be;
-Alarm is turned on
-Alarm searches for IR light
-When IR light is detected, The bi-color LED changes from Red to Green
-When something interrupts the IR detection (someone walks past) the bi-color LED becomes red again and the sound plays
-the alarm_out pin (P14) is turned on, setting off the keypad's micro-controller
-the song loops until the keypad code is correctly put in (this turns on valid_code_in, P15, which is the trigger for resetting the system)
-once valid_code_in is active, the entire thing resets
my current code is also included
In state 0 the alarm is off, the detector is not monitored, and the keypad is checked for a valid code to turn the system on and change the state to 1.
In state 1 the alarm is off, the detector is monitored, and the keypad is checked for a valid code to turn the system off and change the state back to 0.
If the detector is triggered the state is changed to 2, the alarm is turned on, and the keypad is checked for a valid code to turn the system off and change the state to 0.