Hi! good day to all,
I have a simple question regarding my 2 buttons I want my buttons to work simultaneously. the problems are when I pressed the first button the other button is not working, I need to wait for the first button to finish before the other button works.
The delay() function causes the code to block. During a delay() the processor is doing noting. Look at the blink wthout delay example in the IDE examples and do a search for the several things at a time tutorial to learn how to write code withiut delay() (non-blocking code).
follow up question its weird when I pressed the first button the LED works but the buzzer's not but when I pressed both buttons the buzzers work along with the LED's!.
How are the switches wired? Do you have a pullup or pulldown resistor installed?
The common way to wire switches is one side to ground and the other side to an input with its pinMode set to INPUT_PULLUP. The switch will read HIGH when not pressed and LOW when pressed.
If the only thing that you have done is removing these two lines of code and did nothing else
it is vey normal that your code now works different than with having these two lines of code.
You will have to change the code to work non-blocking.
Writing code that is non-blocking works different than blocking code that uses delay()
Again: with delay() you can do nothing else than wait until the delay() has finished.
And this is the reason way it must be coded non-blocking.