
157Chapter 8: Rotary Encoder Control
the push-button pin is pulled LOW, we increase the value of our counter
variable, as well as add a small delay to avoid registering more than one
press at a time.
The next conditional statement in our program has just one job:
Keep track of the value of our counter variable so its value doesn’t
become larger than the number of motors we have. We need our
counter to reset to a value of 1 each time it becomes larger than
a value of 5. Therefore, our conditional statement waits until our
variable reaches a value of 6, then reassigns its value to 1, thereby
resetting the value of the variable back to 1 and starting ...