I want to detect if a push button was pressed and released again. So I thought the right approach would be to first wait while the pin yields LOW and then wait while the pin yields HIGH:
void push(int pin) {
// wait until button was pushed down...
while (digitalRead(pin) == LOW);
// ... and released again
while (digitalRead(pin) == HIGH);
}
That function can be easily reused. The code works fine, but I am just wondering if that solution is considered clean and a good practice.