So far, we have seen how to use the push buttons to change the speed of the DC motor. The previous sketch is written to continuously loop and check for the state of each push button one by one in a sequential manner. First the sketch checks button 1, followed by button 2, and then button 3 - this sequence of checking the state of the buttons continues endlessly. This method of checking for user input may lead to timing issues. Let us understand how.
Let us say you press button 3 (to stop the motor) and at that point in time, if the sketch was checking the state of button 1, then we would have to wait for the sketch to first finish checking button 1, then button 2, and finally button 3 would be checked. Since our sketch is small in size and not doing too many things, you will hardly notice any issues. However, in real-world situations, this is not an ideal...