The code works really great, but how can I improve it with this?:
When I press a button, next time the door is open (distance <10 ) a buzzer should beep. But only next time, after pressing the button.
This way you can be announced by the buzer when the door is open and the person is leaving.
I was thinking something like:
bool PressedToEnter = false;
I was thinking:
If digitalread button HIGH {
PressedToEnter == true
}
else {
PressedToEnter == false
}
If PressedToEnter == true && distance < 10 {
Buzzer
Delay
Buzzer
Delay
Buzzer
PressedToEnter == false
}
Will it work? Or there is a better way to do it.