06-11-2019 10:30 AM
Hello guys
I'm trying to develop an alarm system for a house. As you can see in the attachment I did the alarm system with 3 code attempts but also liked to implement beyond the 3 attempts, wanted to put 20 seconds as time limit to be able to insert the code, after spending that time just wanted to run finished.
Thank you
06-11-2019 10:43 AM - edited 06-11-2019 10:58 AM
You need a WHILE loop instead of a FOR loop.
@jpeyroteo wrote:
As you can see in the attachment I did the alarm system with 3 code attempts but also liked to implement beyond the 3 attempts, wanted to put 20 seconds as time limit to be able to insert the code, after spending that time just wanted to run finished.
It is a really bad idea to stop an alarm system after a certain time, because then it no longer protects your house. I guess you want to give an alarm in no valid disarm code is entered during a certain time frame.
06-11-2019 10:47 AM - edited 06-11-2019 11:00 AM
Also, please do a few basic tutorials, because most of your ode is extremely convoluted. Your inner FOR loop does not make a lot of sense. What is it supposed to do? You can compare the two arrays directly. The "equal TRUE" part can be deleted without any change in functionality, it just returns the original input.
Look into state machine architecture. There are plenty of examples and design templates.
06-11-2019 11:16 AM
@altenbach escreveu:
Also, please do a few basic tutorials, because most of your ode is extremely convoluted. Your inner FOR loop does not make a lot of sense. What is it supposed to do? You can compare the two arrays directly. The "equal TRUE" part can be deleted without any change in functionality, it just returns the original input.
Look into state machine architecture. There are plenty of examples and design templates.
I know this but this is project for the school and teacher asked besides the 3 wrong codes, either a time limit of 20 seconds, that is, if you put the 3 wrong codes to stop the program or if you spend the 20 seconds the program stops .
06-11-2019 11:22 AM
I assume you tried to solve this. Where did you get stuck?
Did you learn about the various timing functions in class?
You need to have at least two shift registers: One to increment the count for each wrong entry and one to store the relative start time reference so you can know when 20 seconds are up. Go over your class notes and read the section about shift registers again. It should all fall in place easily. 😉