I have a project for school to make a doorbell for a pharmacy. when someone rings the bell a led lights up in the pharmacy and when the pharmacist pushes a button the led goes out and the door opens. but when the pharmacist doesn't open whitin 5min (2,5sec in my program) a buzzer goes off untill the door is opened.
my problem is that i cant open the door untill the buzzer goes off.
Please take some time to read this forums manual (click !)
It will help you to use the forum the best way possible, and how you can help us helping you.
Your problem is that you look for button1 to be pressed, after which you go to a fixed piece of code that has to be handled without any dependencies.
So button1 always invokes the LED to be lit, always waits 2.5 seconds, and always sounds the buzzer.
Once in that part of your code, there's no way to avoid any of the mentioned steps above.
Only after you have left that part, you will check button2 which will, if pressed, stop the buzzer and move something to open the door.
You need some extra steps in the part where you look for button1 to be pressed.
By the way, the delays supposed to handle bounce (contactdender) make no sense at all, and will not do what you seem to expect it to do.
There will be some more things to smooth out your sketch and be smart about some possibilities with those buttons, but that's for later.
Wanneer je dit liever in het Nederlands wil afhandelen, moet je op report to moderator onder je post klikken (of hier), en vragen of dit onderwerp naar het Nederlandstalige deel verplaatst kan worden.
Trust me, learning how to use timers and multitask the arduino effectively using them is a CRITICAL skill that may seem a little pointless now, but will save your skin MANY times later on down the line