Buttons and Blinkenlights
Part 4 of the Digital I/O assignment. The circuit is as described in the assignment: two buttons, three LEDs. LEDs are controlled independently by two digital switches controlled by the buttons.
The software is somewhat more clever than expected. To avoid delays() which hinder button responsiveness, I use millis() to track current time and do not throttle the run loop. Also, by keeping track of the previous button state, a single button push yields a single increment to the counter.
The right button and left buttons respectively increment and decrement a counter variable, which reflects the rate at which LEDs blink. The counter variable spans the range [0,7], and it’s current value is reflected in binary on the LED display.
Arduino Sketch: smus_blink_counter